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.
---
lib/PublicInbox/View.pm | 39 ++++++++++-----------------------------
1 file 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: <<a\nhref="../$href/">$html</a>>
-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);
- "<<a\nhref=\"../$href/\">$html</a>>";
-}
-
sub ghost_parent {
my ($upfx, $mid) = @_;