* [PATCH] mid: compress Message-IDs with '%' in them
@ 2015-08-17 7:52 Eric Wong
2015-08-17 8:00 ` [PATCH] search: bump schema version for '%' compression change Eric Wong
0 siblings, 1 reply; 2+ messages in thread
From: Eric Wong @ 2015-08-17 7:52 UTC (permalink / raw)
To: meta
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH] search: bump schema version for '%' compression change
2015-08-17 7:52 [PATCH] mid: compress Message-IDs with '%' in them Eric Wong
@ 2015-08-17 8:00 ` Eric Wong
0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2015-08-17 8:00 UTC (permalink / raw)
To: meta
commit 0fea7793b22efd2596983283947ee43687e0cfac
("mid: compress Message-IDs with '%' in them")
requires re-indexing of repositories with '%' in Message-IDs :<
---
lib/PublicInbox/Search.pm | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index 862ed6d..2608a58 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -16,7 +16,8 @@ use constant {
# 0 - initial
# 1 - subject_path is lower-cased
# 2 - subject_path is mid_compressed in the index, only
- SCHEMA_VERSION => 2,
+ # 3 - message-ID is compressed if it includes '%' (hack!)
+ SCHEMA_VERSION => 3,
LANG => 'english',
QP_FLAGS => FLAG_PHRASE|FLAG_BOOLEAN|FLAG_LOVEHATE|FLAG_WILDCARD,
};
--
EW
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-08-17 8:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-17 7:52 [PATCH] mid: compress Message-IDs with '%' in them Eric Wong
2015-08-17 8:00 ` [PATCH] search: bump schema version for '%' compression change Eric Wong
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).