about summary refs log tree commit homepage
path: root/lib/PublicInbox/View.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2022-09-10 08:17:02 +0000
committerEric Wong <e@80x24.org>2022-09-10 19:50:32 +0000
commit404fb35c07290ac4f5f618bac6626573c79ddc50 (patch)
treecc1c1c6649cbfdc4fb2a6baf54ec22a1723276e4 /lib/PublicInbox/View.pm
parentde954cac909d1ec0702a5ba2b0eb1823f999043d (diff)
downloadpublic-inbox-404fb35c07290ac4f5f618bac6626573c79ddc50.tar.gz
Having References but lacking In-Reply-To is an uncommon case
with email, nowadays.  So just rely on ->linkify_mids to handle
linkification and HTML escaping  Furthermore, headers are short
enough to return as-is (and rely on CoW improvements in Perl
5.1x) since linkify_mids needs to operate on an independent
string, anyways.
Diffstat (limited to 'lib/PublicInbox/View.pm')
-rw-r--r--lib/PublicInbox/View.pm39
1 files changed, 10 insertions, 29 deletions
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index c6fd05cc..3980ed91 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -740,8 +740,7 @@ sub _msg_page_prepare_obuf {
                 $ctx->{-linkify}->linkify_mids('..', \$s, 1);
                 $rv .= $s;
         }
-        _parent_headers($ctx, $eml);
-        $rv .= "\n";
+        $rv .= _parent_headers($ctx, $eml);
         1;
 }
 
@@ -795,32 +794,21 @@ sub _parent_headers {
         my ($ctx, $hdr) = @_;
         my @irt = $hdr->header_raw('In-Reply-To');
         my $refs;
-        if (@irt) {
-                my $s = '';
-                $s .= "In-Reply-To: $_\n" for @irt;
-                $ctx->{-linkify}->linkify_mids('..', \$s);
-                ${$ctx->{obuf}} .= $s;
-        } else {
+        my $s = '';
+        if (!@irt) {
                 $refs = references($hdr);
-                my $irt = pop @$refs;
-                if (defined $irt) {
-                        my $html = ascii_html($irt);
-                        my $href = mid_href($irt);
-                        ${$ctx->{obuf}} .= <<EOM;
-In-Reply-To: &lt;<a\nhref="../$href/">$html</a>&gt;
-EOM
-                }
+                $irt[0] = pop(@$refs) if scalar @$refs;
         }
+        $s .= "In-Reply-To: $_\n" for @irt;
 
         # do not display References: if search is present,
         # we show the thread skeleton at the bottom, instead.
-        return if $ctx->{ibx}->over;
-
-        $refs //= references($hdr);
-        if (@$refs) {
-                $_ = linkify_ref_no_over($_) for @$refs;
-                ${$ctx->{obuf}} .= 'References: '. join("\n\t", @$refs) . "\n";
+        if (!$ctx->{ibx}->over) {
+                $refs //= references($hdr);
+                $s .= 'References: <'.join(">\n\t<", @$refs).">\n" if @$refs;
         }
+        $ctx->{-linkify}->linkify_mids('..', \$s); # escapes HTML
+        $s .= "\n";
 }
 
 # appends to obuf
@@ -901,13 +889,6 @@ EOF
         $ctx->zmore($skel .= msg_reply($ctx, $hdr)); # flushes obuf
 }
 
-sub linkify_ref_no_over {
-        my ($mid) = @_;
-        my $href = mid_href($mid);
-        my $html = ascii_html($mid);
-        "&lt;<a\nhref=\"../$href/\">$html</a>&gt;";
-}
-
 sub ghost_parent {
         my ($upfx, $mid) = @_;