Skip Menu |
 

This queue is for tickets about the Encode CPAN distribution.

Report information
The Basics
Id: 24418
Status: resolved
Priority: 0/
Queue: Encode

People
Owner: Nobody in particular
Requestors: SREZIC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 2.18
Fixed in: (no value)



Subject: Encode::MIME::Header: wrong encoding with latin1 characters
MIME-Version: 1.0
X-Mailer: MIME-tools 5.418 (Entity 5.418)
X-RT-Original-Encoding: utf-8
Content-Type: multipart/mixed; boundary="----------=_1169051488-21079-9"
Content-Length: 0
Content-Type: text/plain; charset="utf8"
Content-Disposition: inline
Content-Transfer-Encoding: binary
Content-Length: 734
Download (untitled) / with headers
text/plain 734b
MIME-Q encoding works wrong if the string has high bit characters, but no utf8 flag. The following should return an encoded two-byte utf8 string: $ perl -MEncode=encode -e 'warn encode ("MIME-Q", "\x{fc}")' =?UTF-8?Q?=FC?= at -e line 1. The expected output when forcing the utf8 flag on the string: $ perl -MEncode=encode -e 'warn encode ("MIME-Q", substr("\x{fc}\x{100}",0,-1))' =?UTF-8?Q?=C3=BC?= at -e line 1. The attached patch solves the problem (by adding the missing encode_utf8). Also, I removed decode_utf8 some lines later, because it seems to be unnecessary in this context --- after conversion, the string should only contain ascii characters. Also included in the patch is the above test case. Regards, Slaven
Subject: encode-mime.patch
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----------=_1169051486-21079-8"
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Length: 0
Content-Type: text/plain; charset="utf8"
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 0
Content-Type: application/octet-stream; name="encode-mime.patch"
Content-Disposition: inline; filename="encode-mime.patch"
Content-Transfer-Encoding: base64
Content-Length: 3291
Download encode-mime.patch
text/x-diff 3.2k
# # # To apply this patch: # STEP 1: Chdir to the source directory. # STEP 2: Run the 'applypatch' program with this patch file as input. # # If you do not have 'applypatch', it is part of the 'makepatch' package # that you can fetch from the Comprehensive Perl Archive Network: # http://www.perl.com/CPAN/authors/Johan_Vromans/makepatch-x.y.tar.gz # In the above URL, 'x' should be 2 or higher. # # To apply this patch without the use of 'applypatch': # STEP 1: Chdir to the source directory. # STEP 2: Run the 'patch' program with this file as input. # #### End of Preamble #### #### Patch data follows #### diff -up 'build/Encode-2.18-C92yHm/lib/Encode/MIME/Header.pm' 'new.build/Encode-2.18-C92yHm/lib/Encode/MIME/Header.pm' Index: ./lib/Encode/MIME/Header.pm --- ./lib/Encode/MIME/Header.pm Sat Jun 3 22:29:02 2006 +++ ./lib/Encode/MIME/Header.pm Wed Jan 17 17:23:01 2007 @@ -174,12 +174,13 @@ sub _encode_b { sub _encode_q { my $chunk = shift; + $chunk = encode_utf8($chunk); $chunk =~ s{ ([^0-9A-Za-z]) }{ join("" => map {sprintf "=%02X", $_} unpack("C*", $1)) }egox; - return decode_utf8( HEAD . 'Q?' . $chunk . TAIL ); + return HEAD . 'Q?' . $chunk . TAIL; } 1; diff -up 'build/Encode-2.18-C92yHm/t/mime-header.t' 'new.build/Encode-2.18-C92yHm/t/mime-header.t' Index: ./t/mime-header.t Prereq: 2.2 --- ./t/mime-header.t Sat Jun 3 22:29:03 2006 +++ ./t/mime-header.t Wed Jan 17 17:10:45 2007 @@ -23,7 +23,7 @@ no utf8; use strict; #use Test::More qw(no_plan); -use Test::More tests => 11; +use Test::More tests => 12; use_ok("Encode::MIME::Header"); my $eheader =<<'EOS'; @@ -116,4 +116,7 @@ is(Encode::encode('MIME-Q', $dheader), $ is(Encode::encode('MIME-Q' => $pound_1024), '=?UTF-8?Q?=C2=A31024?=', 'pound 1024'); } + +is(Encode::encode('MIME-Q', "\x{fc}"), '=?UTF-8?Q?=C3=BC?=', 'Encode latin1 characters'); + __END__; #### End of Patch data #### #### ApplyPatch data follows #### # Data version : 1.0 # Date generated : Wed Jan 17 17:27:34 2007 # Generated by : makepatch 2.00_11* # Recurse directories : Yes # Excluded files : (\A|/).*\~\Z # (\A|/).*\.a\Z # (\A|/).*\.bak\Z # (\A|/).*\.BAK\Z # (\A|/).*\.elc\Z # (\A|/).*\.exe\Z # (\A|/).*\.gz\Z # (\A|/).*\.ln\Z # (\A|/).*\.o\Z # (\A|/).*\.obj\Z # (\A|/).*\.olb\Z # (\A|/).*\.old\Z # (\A|/).*\.orig\Z # (\A|/).*\.rej\Z # (\A|/).*\.so\Z # (\A|/).*\.Z\Z # (\A|/)\.del\-.*\Z # (\A|/)\.make\.state\Z # (\A|/)\.nse_depinfo\Z # (\A|/)core\Z # (\A|/)tags\Z # (\A|/)TAGS\Z # p 'lib/Encode/MIME/Header.pm' 6855 1169050981 0100644 # p 't/mime-header.t' 4258 1169050245 0100755 #### End of ApplyPatch data #### #### End of Patch kit [created: Wed Jan 17 17:27:34 2007] #### #### Patch checksum: 76 2633 35712 #### #### Checksum: 94 3257 21705 ####
MIME-Version: 1.0
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Disposition: inline
Message-Id: <rt-3.6.HEAD-16527-1175857642-1752.24418-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Original-Encoding: utf-8
Content-Length: 867
Download (untitled) / with headers
text/plain 867b
Thanks, applied. Dan the Maintainer Thereof On Wed Jan 17 11:31:32 2007, SREZIC wrote: Show quoted text
> MIME-Q encoding works wrong if the string has high bit characters, but > no utf8 flag. The following should return an encoded two-byte utf8 string: > > $ perl -MEncode=encode -e 'warn encode ("MIME-Q", "\x{fc}")' > =?UTF-8?Q?=FC?= at -e line 1. > > The expected output when forcing the utf8 flag on the string: > > $ perl -MEncode=encode -e 'warn encode ("MIME-Q", > substr("\x{fc}\x{100}",0,-1))' > =?UTF-8?Q?=C3=BC?= at -e line 1. > > The attached patch solves the problem (by adding the missing > encode_utf8). Also, I removed decode_utf8 some lines later, because it > seems to be unnecessary in this context --- after conversion, the string > should only contain ascii characters. > > Also included in the patch is the above test case. > > Regards, > Slaven


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.