unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH] mid: no wide characters for sha1_hex
@ 2016-08-14 10:34 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2016-08-14 10:34 UTC (permalink / raw)
  To: meta

Apparently there are some really screwed up In-Reply-To
fields out there.
---
 lib/PublicInbox/MID.pm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/PublicInbox/MID.pm b/lib/PublicInbox/MID.pm
index 78952b9..bb40cc7 100644
--- a/lib/PublicInbox/MID.pm
+++ b/lib/PublicInbox/MID.pm
@@ -25,6 +25,7 @@ sub id_compress {
 	my ($id, $force) = @_;
 
 	if ($force || $id =~ /[^\w\-]/ || length($id) > MID_MAX) {
+		utf8::encode($id);
 		return sha1_hex($id);
 	}
 	$id;
@@ -36,7 +37,9 @@ sub mid2path {
 
 	unless (defined $x38) {
 		# compatibility with old links (or short Message-IDs :)
-		$mid = sha1_hex(mid_clean($mid));
+		$mid = mid_clean($mid);
+		utf8::encode($mid);
+		$mid = sha1_hex($mid);
 		($x2, $x38) = ($mid =~ /\A([a-f0-9]{2})([a-f0-9]{38})\z/);
 	}
 	"$x2/$x38";
-- 
EW


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-08-14 10:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-14 10:34 [PATCH] mid: no wide characters for sha1_hex 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).