From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-3.3 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, RP_MATCHES_RCVD shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: meta@public-inbox.org Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 18B131F81A for ; Mon, 17 Aug 2015 07:52:11 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] mid: compress Message-IDs with '%' in them Date: Mon, 17 Aug 2015 07:52:11 +0000 Message-Id: <1439797931-27484-1-git-send-email-e@80x24.org> List-Id: 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 | 8 ++++++++ t/view.t | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/PublicInbox/MID.pm b/lib/PublicInbox/MID.pm index d097011..c75aa0e 100644 --- a/lib/PublicInbox/MID.pm +++ b/lib/PublicInbox/MID.pm @@ -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); } diff --git a/t/view.t b/t/view.t index 3107285..463fc07 100644 --- 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(); -- EW