]> Sergey Matveev's repositories - public-inbox.git/commitdiff
view: move '<' and '>' outside <a>
authorEric Wong <e@80x24.org>
Thu, 24 Oct 2019 00:12:37 +0000 (00:12 +0000)
committerEric Wong <e@80x24.org>
Mon, 28 Oct 2019 10:49:08 +0000 (10:49 +0000)
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
t/psgi_v2.t

index 1aa014fdd2397c6f508c4316ce83c3938d7e5bb0..855ad017a6bfd8f4243a778a5401eadff0aabd47 100644 (file)
@@ -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);
index cb5ece638b1d79f334ab96f90ff30ba7585f62d9..c7550e2d1e84355e6cc17c41e5ec3af80f98b2b1 100644 (file)
@@ -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');