]> Sergey Matveev's repositories - public-inbox.git/commitdiff
mid: no wide characters for sha1_hex
authorEric Wong <e@80x24.org>
Sun, 14 Aug 2016 10:21:11 +0000 (10:21 +0000)
committerEric Wong <e@80x24.org>
Sun, 14 Aug 2016 10:33:02 +0000 (10:33 +0000)
Apparently there are some really screwed up In-Reply-To
fields out there.

lib/PublicInbox/MID.pm

index 78952b95e02f1eb94a6876017bc6c8e6a911978c..bb40cc76232152e38242d0d13fb595fc3b35e89d 100644 (file)
@@ -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";