]> Sergey Matveev's repositories - public-inbox.git/commitdiff
view: always compress Message-IDs for anchors
authorEric Wong <e@80x24.org>
Mon, 17 Aug 2015 08:05:03 +0000 (08:05 +0000)
committerEric Wong <e@80x24.org>
Mon, 17 Aug 2015 08:05:03 +0000 (08:05 +0000)
Valid URLs do not make valid anchor ids.

lib/PublicInbox/MID.pm
lib/PublicInbox/View.pm

index c75aa0e166ec3709515d0a3825c789006ec5d0fd..2f0c09fb843e770b9307fcca31405ec4fd362275 100644 (file)
@@ -19,7 +19,7 @@ sub mid_clean {
 
 # this is idempotent
 sub mid_compressed {
-       my ($mid) = @_;
+       my ($mid, $force) = @_;
 
        # XXX dirty hack! FIXME!
        # Some HTTP servers (apache2 2.2.22-13+deb7u5 on my system)
@@ -28,7 +28,7 @@ sub mid_compressed {
        # or what; will need to debug...
        return sha1_hex($mid) if (index($mid, '%') >= 0);
 
-       return $mid if (length($mid) <= MID_MAX);
+       return $mid if (!$force && length($mid) <= MID_MAX);
        sha1_hex($mid);
 }
 
index 55e12f261cb851517be1e596281b7a2356f39550..e7ca73dc0660aa79054cf5b1acc38e6a78cff249 100644 (file)
@@ -477,7 +477,7 @@ sub linkify_refs {
 
 sub anchor_for {
        my ($msgid) = @_;
-       'm' . mid_compressed(mid_clean($msgid));
+       'm' . mid_compressed(mid_clean($msgid), 1);
 }
 
 sub simple_dump {