]> Sergey Matveev's repositories - public-inbox.git/commitdiff
view: do not recompress already-compressed MID for anchors
authorEric Wong <e@80x24.org>
Mon, 17 Aug 2015 20:15:31 +0000 (20:15 +0000)
committerEric Wong <e@80x24.org>
Mon, 17 Aug 2015 20:15:31 +0000 (20:15 +0000)
This is merely for display, so on the off chance somebody does
send a 40-byte MID with nothing but hexadecimal characters,
the worst that could happen is we repeat an anchor name in the
rendered HTML.  This has no impact on git archival or Xapian
indexing.

lib/PublicInbox/View.pm

index e7ca73dc0660aa79054cf5b1acc38e6a78cff249..6fbc366027d0c2d1eda266de34ca95c5d8ba4a2d 100644 (file)
@@ -477,7 +477,11 @@ sub linkify_refs {
 
 sub anchor_for {
        my ($msgid) = @_;
-       'm' . mid_compressed(mid_clean($msgid), 1);
+       my $id = $msgid;
+       if ($id !~ /\A[a-f0-9]{40}\z/) {
+               $id = mid_compressed(mid_clean($id), 1);
+       }
+       'm' . $id;
 }
 
 sub simple_dump {