From 23de6ffe65656114bfdbdb6649dbbfcdffaf5a5c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 27 Apr 2014 06:21:57 +0000 Subject: feeds use XHTML to avoid tag soup This should work in most browsers, lets find out! --- lib/PublicInbox/Hval.pm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'lib/PublicInbox/Hval.pm') diff --git a/lib/PublicInbox/Hval.pm b/lib/PublicInbox/Hval.pm index 09ae2676..1a83cf10 100644 --- a/lib/PublicInbox/Hval.pm +++ b/lib/PublicInbox/Hval.pm @@ -7,7 +7,6 @@ use strict; use warnings; use fields qw(raw); use Encode qw(find_encoding); -use CGI qw(escapeHTML); use URI::Escape qw(uri_escape); my $enc_ascii = find_encoding('us-ascii'); @@ -38,7 +37,19 @@ sub new_oneline { $class->new($raw); } -sub ascii_html { $enc_ascii->encode(escapeHTML($_[0]), Encode::HTMLCREF) } +my %xhtml_map = ( + '"' => '"', + '&' => '&', + "'" => ''', + '<' => '<', + '>' => '>', +); + +sub ascii_html { + my ($s) = @_; + $s =~ s/([<>&'"])/$xhtml_map{$1}/ge; + $enc_ascii->encode($s, Encode::HTMLCREF); +} sub as_html { ascii_html($_[0]->{raw}) } sub as_href { ascii_html(uri_escape($_[0]->{raw})) } -- cgit v1.2.3-24-ge0c7