unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] mid: compress Message-IDs with '%' in them
Date: Mon, 17 Aug 2015 07:52:11 +0000	[thread overview]
Message-ID: <1439797931-27484-1-git-send-email-e@80x24.org> (raw)

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


             reply	other threads:[~2015-08-17  7:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-17  7:52 Eric Wong [this message]
2015-08-17  8:00 ` [PATCH] search: bump schema version for '%' compression change Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1439797931-27484-1-git-send-email-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).