From 49d99dc0f71ab2d0f23a074765ef10d55d5d5547 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 24 Dec 2015 01:56:22 +0000 Subject: repobrowse: /commit/ forces everything to UTF-8 Hopefully we'll show some names properly in our pages now, as well as simplify our code when escaping text for HTML display. Additionally, tweak our diff display by using and tags for added/removed text, respectively. This should allow users to choose their own styles when viewing diffs in their browser while being meaningful to people who cannot differentiate colors. --- lib/PublicInbox/Hval.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/PublicInbox/Hval.pm') diff --git a/lib/PublicInbox/Hval.pm b/lib/PublicInbox/Hval.pm index a16cd4a1..2974c683 100644 --- a/lib/PublicInbox/Hval.pm +++ b/lib/PublicInbox/Hval.pm @@ -10,7 +10,7 @@ use Encode qw(find_encoding); use URI::Escape qw(uri_escape_utf8); use PublicInbox::MID qw/mid_clean/; use base qw/Exporter/; -our @EXPORT_OK = qw/ascii_html/; +our @EXPORT_OK = qw/ascii_html utf8_html/; # for user-generated content (UGC) which may have excessively long lines # and screw up rendering on some browsers. This is the only CSS style @@ -71,6 +71,11 @@ sub ascii_html { $enc_ascii->encode($s, Encode::HTMLCREF); } +sub utf8_html { + my ($raw) = @_; + ascii_html($enc_utf8->decode($raw)); +} + sub as_html { ascii_html($_[0]->{raw}) } sub as_href { ascii_html(uri_escape_utf8($_[0]->{href})) } -- cgit v1.2.3-24-ge0c7