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
"&lt;" and "&gt;" outside of <a> 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: &lt;$mhtml&gt; ";
+               $rv .= "(<a\nhref=\"raw\">raw</a>)\n";
+       } else {
+               foreach (@$mids) {
+                       my $mid = PublicInbox::Hval->new_msgid($_);
+                       my $mhtml = $mid->as_html;
                        my $href = $mid->{href};
                        $rv .= "Message-ID: ";
-                       $rv .= "<a\nhref=\"../$href/\">";
-                       $rv .= "&lt;$mhtml&gt;</a> ";
+                       $rv .= "&lt;<a\nhref=\"../$href/\">$mhtml</a>&gt; ";
                        $rv .= "(<a\nhref=\"../$href/raw\">raw</a>)\n";
-               } else {
-                       $rv .= "Message-ID: &lt;$mhtml&gt; ";
-                       $rv .= "(<a\nhref=\"raw\">raw</a>)\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/&lt;\Q$mid\E&gt;/s, "Message-ID $mid shown");
+               like($raw, qr!>\Q$mid\E</a>!s, "Message-ID $mid shown");
        }
        like($raw, qr/\b3\+ messages\b/, 'thread overview shown');
 
--
unsubscribe: [email protected]
archive: https://public-inbox.org/meta/

Reply via email to