]> Sergey Matveev's repositories - public-inbox.git/commitdiff
mid: compress Message-IDs with '%' in them
authorEric Wong <e@80x24.org>
Mon, 17 Aug 2015 07:46:54 +0000 (07:46 +0000)
committerEric Wong <e@80x24.org>
Mon, 17 Aug 2015 07:51:53 +0000 (07:51 +0000)
Some HTTP servers (apache2 2.2.22-13+deb7u5) on my system
apparently do not handle "%25" correctly.  I'm not yet sure if
it's something weird with my rewrite rules or what....

lib/PublicInbox/MID.pm
t/view.t

index d097011bf4ae21b58075def04f2306cd66a22f54..c75aa0e166ec3709515d0a3825c789006ec5d0fd 100644 (file)
@@ -20,6 +20,14 @@ sub mid_clean {
 # this is idempotent
 sub mid_compressed {
        my ($mid) = @_;
+
+       # XXX dirty hack! FIXME!
+       # Some HTTP servers (apache2 2.2.22-13+deb7u5 on my system)
+       # apparently do not handle "%25" in the URL path component correctly.
+       # I'm not yet sure if it's something weird with my rewrite rules
+       # or what; will need to debug...
+       return sha1_hex($mid) if (index($mid, '%') >= 0);
+
        return $mid if (length($mid) <= MID_MAX);
        sha1_hex($mid);
 }
index 3107285c1dd0dbfb7e4c6cf7a937ca291db23f00..463fc0764d9a9e2587e72a038c719a5926d10255 100644 (file)
--- a/t/view.t
+++ b/t/view.t
@@ -144,4 +144,13 @@ EOF
        like($html, qr/\bhi = bye\b/, "HTML output decoded QP");
 }
 
+
+{      # XXX dirty hack
+       use PublicInbox::MID qw/mid_compressed/;
+       like(mid_compressed('foo%bar@wtf'), qr/\A[a-f0-9]{40}\z/,
+               "percent always converted to sha1 to workaround buggy httpds");
+       is(mid_compressed('foobar@wtf'), 'foobar@wtf',
+               'regular MID not compressed');
+}
+
 done_testing();