From d2786235a289a0286d96a9b853b7a0a30a6f6b5a Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 24 Oct 2019 00:12:37 +0000 Subject: [PATCH] view: move '<' and '>' outside MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Browsers may underline '<' and '>' in links, which may be confused with '≤' and '≥'. So have the Message-ID header display follow what we do with In-Reply-To headers and move the "<" and ">" outside of in the HTML. --- lib/PublicInbox/View.pm | 18 +++++++++--------- t/psgi_v2.t | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 1aa014fd..855ad017 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -630,7 +630,6 @@ sub _msg_html_prepare { my $obfs_ibx = $ctx->{-obfs_ibx}; my $rv = ''; my $mids = mids($hdr); - my $multiple = scalar(@$mids) > 1; # zero, one, infinity if ($nr == 0) { if ($more) { $rv .= @@ -686,18 +685,19 @@ sub _msg_html_prepare { $rv .= "Date: $v\n"; } $ctx->{-title_html} = join(' - ', @title); - foreach (@$mids) { - my $mid = PublicInbox::Hval->new_msgid($_) ; + if (scalar(@$mids) == 1) { # common case + my $mid = PublicInbox::Hval->new_msgid($mids->[0]); my $mhtml = $mid->as_html; - if ($multiple) { + $rv .= "Message-ID: <$mhtml> "; + $rv .= "(raw)\n"; + } else { + foreach (@$mids) { + my $mid = PublicInbox::Hval->new_msgid($_); + my $mhtml = $mid->as_html; my $href = $mid->{href}; $rv .= "Message-ID: "; - $rv .= ""; - $rv .= "<$mhtml> "; + $rv .= "<$mhtml> "; $rv .= "(raw)\n"; - } else { - $rv .= "Message-ID: <$mhtml> "; - $rv .= "(raw)\n"; } } $rv .= _parent_headers($hdr, $over); diff --git a/t/psgi_v2.t b/t/psgi_v2.t index cb5ece63..c7550e2d 100644 --- a/t/psgi_v2.t +++ b/t/psgi_v2.t @@ -168,7 +168,7 @@ test_psgi(sub { $www->call(@_) }, sub { @from_ = ($raw =~ m/>From: /mg); is(scalar(@from_), 3, 'three From: lines'); foreach my $mid ('a-mid@b', $new_mid, $third) { - like($raw, qr/<\Q$mid\E>/s, "Message-ID $mid shown"); + like($raw, qr!>\Q$mid\E!s, "Message-ID $mid shown"); } like($raw, qr/\b3\+ messages\b/, 'thread overview shown'); -- 2.44.0