about summary refs log tree commit
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-04-24 21:56:53 +0000
committerEric Wong <e@80x24.org>2019-04-24 22:40:17 +0000
commit3b6e9cd2a321b15d7042b8a5e2af2bfe6781d4e0 (patch)
tree050654ee6ec5051abf99f22c2cdd7380496b9403
parentcd2ad4db42f89fd134f39816b625657700c365d2 (diff)
downloadpublic-inbox-3b6e9cd2a321b15d7042b8a5e2af2bfe6781d4e0.tar.gz
Not all inputs are highlight-able, so reuse the original
input and just linkify it if it can't be highlighted.
-rw-r--r--lib/PublicInbox/WwwHighlight.pm7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/PublicInbox/WwwHighlight.pm b/lib/PublicInbox/WwwHighlight.pm
index d8101b75..bc349f8a 100644
--- a/lib/PublicInbox/WwwHighlight.pm
+++ b/lib/PublicInbox/WwwHighlight.pm
@@ -25,6 +25,7 @@ use bytes (); # only for bytes::length
 use HTTP::Status qw(status_message);
 use parent qw(PublicInbox::HlMod);
 use PublicInbox::Linkify qw();
+use PublicInbox::Hval qw(ascii_html);
 
 # TODO: support highlight(1) for distros which don't package the
 # SWIG extension.  Also, there may be admins who don't want to
@@ -67,7 +68,11 @@ sub call {
         my $bref = read_in_full($env) or return r(500);
         my $l = PublicInbox::Linkify->new;
         $l->linkify_1($$bref);
-        $bref = $self->do_hl($bref, $env->{PATH_INFO});
+        if (my $res = $self->do_hl($bref, $env->{PATH_INFO})) {
+                $bref = $res;
+        } else {
+                $$bref = ascii_html($$bref);
+        }
         $l->linkify_2($$bref);
 
         my $h = [ 'Content-Type', 'text/html; charset=UTF-8' ];