Skip Menu |

This queue is for tickets about the MIME-Lite CPAN distribution.

Report information
The Basics
Id: 39334
Status: resolved
Priority: 0/
Queue: MIME-Lite

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

Bug Information
Severity: Critical
Broken in: (no value)
Fixed in: 3.021



Subject: weird unicode mess when using some regexps UNRELATED to object!
hi I mark this bug as critical because it should NOT happen... ever... GOOD EXAMPLE ---------------- 8< ---------------- #!/usr/bin/perl use strict; use warnings; use utf8; use MIME::Lite; use Encode; my $msg = MIME::Lite->new( 'From' => '"X" <x@bbkr.org>', 'To' => '"Y" <y@bbkr.org>', 'Subject' => 'Hello', 'Type' => 'text/plain', 'Encoding' => 'quoted-printable', 'Data' => Encode::encode_utf8('zażółć gęślą jaźń'), ); $msg->attr('Content-Type.charset' => 'utf8'); print $msg->body_as_string(); ---------------- 8< ---------------- this GOOD example prints as expected: ---------------- 8< ---------------- za=C5=BC=C3=B3=C5=82=C4=87 g=C4=99=C5=9Bl=C4=85 ja=C5=BA=C5=84= ---------------- 8< ---------------- BAD EXAMPLE ---------------- 8< ---------------- #!/usr/bin/perl use strict; use warnings; use utf8; use MIME::Lite; use Encode; my $msg = MIME::Lite->new( 'From' => '"X" <x@bbkr.org>', 'To' => '"Y" <y@bbkr.org>', 'Subject' => 'Hello', 'Type' => 'text/plain', 'Encoding' => 'quoted-printable', 'Data' => Encode::encode_utf8('zażółć gęślą jaźń'), ); $msg->attr('Content-Type.charset' => 'utf8'); my $unrelated = 'Śómę Uńićodę'; # NEW $unrelated =~ s/(?<=\b)(\S)/\U$1/g; # NEW print $msg->body_as_string(); ---------------- 8< ---------------- And this dies with following message: ---------------- 8< ---------------- Wide character in subroutine entry at /usr/lib/perl5/vendor_perl/5.8.8/MIME/Lite.pm line 2262. ---------------- 8< ---------------- So completly UNRELATED code (even executed in some other namespace) can mess MIME::Lite object. Please fix it fast :)
It is BROKEN in 3.021, not fixed. Sorry about misclick.
This smells like a bug in perl. Adding a (basically) no-op line like in the attached patch seems to fix the problem. If looking at the $1 value before the "$line = $1" line, it looks like this (note the "U" in the PV value): SV = PVMG(0x818c8d8) at 0x8178f28 REFCNT = 1 FLAGS = (GMG,SMG,READONLY,pPOK,UTF8) IV = 0 NV = 0 PV = 0x83a94f0 "U"\0 [UTF8 "U"] CUR = 1 LEN = 8 MAGIC = 0x81b03a0 MG_VIRTUAL = &PL_vtbl_sv MG_TYPE = PERL_MAGIC_sv(\0) MG_OBJ = 0x8178f1c MG_LEN = 1 MG_PTR = 0x81b0490 "1" After the assignment it looks correct: SV = PVMG(0x818c8d8) at 0x8178f28 REFCNT = 1 FLAGS = (GMG,SMG,READONLY,pPOK) IV = 0 NV = 0 PV = 0x83a0e80 "za\305\274\303\263\305\202\304\207 g\304\231\305\233l\304\205 ja\305\272\305\204"\0 CUR = 26 LEN = 28 MAGIC = 0x81b03a0 MG_VIRTUAL = &PL_vtbl_sv MG_TYPE = PERL_MAGIC_sv(\0) MG_OBJ = 0x8178f1c MG_LEN = 1 MG_PTR = 0x81b0490 "1" Regards, Slaven
--- /usr/share/perl5/MIME/Lite.pm 2008-02-16 11:45:11.000000000 +0100 +++ MIME/Lite.pm 2008-10-30 11:06:40.000000000 +0100 @@ -2259,7 +2259,8 @@ ### Encode it line by line: while ( $untainted =~ m{^(.*[\r\n]*)}smg ) { - $out->print( encode_qp($1) ); ### have to do it line by line... + my $line = $1; + $out->print( encode_qp($line) ); ### have to do it line by line... } last DATA; };
applied -- rjbs