dumping ground for random patches and texts
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH 2/2] XML val checks
Date: Sun, 14 Aug 2016 03:57:26 +0000	[thread overview]
Message-ID: <20160814035726.4241-2-e@80x24.org> (raw)
In-Reply-To: <20160814035726.4241-1-e@80x24.org>

---
 lib/PublicInbox/Hval.pm | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/PublicInbox/Hval.pm b/lib/PublicInbox/Hval.pm
index b354aa4..38110b1 100644
--- a/lib/PublicInbox/Hval.pm
+++ b/lib/PublicInbox/Hval.pm
@@ -51,10 +51,15 @@ my %xhtml_map = (
 	'>' => '&gt;',
 );
 
+$xhtml_map{chr($_)} = sprintf('\\x%02x', $_) for (0..31);
+$xhtml_map{"\x1b"} = '^['; # ASCII escape (mutt seems to do this)
+$xhtml_map{"\x0a"} = "\n"; # obvious
+$xhtml_map{"\x7f"} = '\\x7f'; # DEL
+
 sub ascii_html {
 	my ($s) = @_;
 	$s =~ s/\r\n/\n/sg; # fixup bad line endings
-	$s =~ s/([<>&'"])/$xhtml_map{$1}/ge;
+	$s =~ s/([<>&'"\x7f\x00-\x1f])/$xhtml_map{$1}/ge;
 	$enc_ascii->encode($s, Encode::HTMLCREF);
 }
 
-- 
EW


      reply	other threads:[~2016-08-14  3:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-14  3:57 [PATCH 1/2] searchview: MID fixup SQUASH Eric Wong
2016-08-14  3:57 ` Eric Wong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160814035726.4241-2-e@80x24.org \
    --to=e@80x24.org \
    --cc=spew@80x24.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).