Subject: | decode('MIME-header') does not properly join similar Q encoded-words |
Date: | Thu, 14 May 2015 17:23:06 +1000 |
To: | bug-Encode [...] rt.cpan.org |
From: | Richard Lovejoy <cpan [...] rjlov.fastmail.fm> |
The regexp designed to join encoded words together needs some
adjustment. The .*? can overrun an encoded-word, meaning that
encoded-words with incompatible charsets or encodings may be combined.
For example:
decode("MIME-Header","=?utf-8?Q?pre?= =?utf-8?B?IGZvbw==?=
=?utf-8?Q?bar?=")
expected: "pre foobar"
actual: "pre foo"
This patch fixes the problem, I believe:
--- old/Encode/MIME/Header.pm 2015-05-14 17:14:41.000000000 +1000
+++ new/Encode/MIME/Header.pm 2015-05-14 17:16:05.800000000 +1000
@@ -47,7 +47,7 @@
$str =~ s/(?:\r\n|[\r\n])[ \t]//gos;
1 while ( $str =~
- s/(=\?[-0-9A-Za-z_]+\?[Qq]\?)(.*?)\?=\1(.*?\?=)/$1$2$3/ )
+ s/(=\?[-0-9A-Za-z_]+\?[Qq]\?)([^?]*?)\?=\1([^?]*?\?=)/$1$2$3/ )
; # Concat consecutive QP encoded mime headers
# Fixes breaking inside multi-byte characters
Richard.
--
Richard Lovejoy