From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 63FF620382 for ; Wed, 24 Apr 2019 23:02:14 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 3/5] wwwhighlight: deal with no-op highlight Date: Wed, 24 Apr 2019 23:02:12 +0000 Message-Id: <20190424230214.2378-4-e@80x24.org> In-Reply-To: <20190424230214.2378-1-e@80x24.org> References: <20190424230214.2378-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Not all inputs are highlight-able, so reuse the original input and just linkify it if it can't be highlighted. --- lib/PublicInbox/WwwHighlight.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/WwwHighlight.pm b/lib/PublicInbox/WwwHighlight.pm index d8101b7..bc349f8 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' ]; -- EW