Subject: | Encode::MIME::Headers patch to solve what is probably someone else's bug |
Yahoo mail in China created the following MIME-Header:
=?gb2312?q?Chinese(gb2312)=20=20=C3=C0=B9=FA=C7=B0=CB=BE=B7=A8=B2=BF=B3?=
=?gb2312?q?=A4=C3=E6=BC=FB=C8=F8=B4=EF=C4=B7=BA=F3=B3=C6=C6=E4=D7=B4=CC=AC?=
=?gb2312?q?=BA=DC=BA=C3=20=20Chinese=20(gb2312)?=
They folded the header in the middle of a character such that the result when
Encode::MIME::Header decodes it, is incorrect. The attached patch allows proper decoding of cases like this (only for QP).
--Scott
--- Encode-2.09/lib/Encode/MIME/Header.pm 2004-12-03 11:17:01.000000000 -0800
+++ Encode-new/lib/Encode/MIME/Header.pm 2005-12-09 17:22:54.000000000 -0800
@@ -47,6 +47,10 @@
$str =~ s/\?=\s+=\?/\?==\?/gos;
# multi-line header to single line
$str =~ s/(:?\r|\n|\r\n)[ \t]//gos;
+
+ 1 while ($str =~ s/(\=\?[0-9A-Za-z\-_]+\?[Qq]\?)(.*?)\?\=\1(.*?)\?\=/$1$2$3\?\=/); # Concat consecutive QP encoded mime headers
+ # Fixes breaking inside multi-byte characters
+
$str =~
s{
=\? # begin encoded word