Skip Menu |

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

Report information
The Basics
Id: 11802
Status: resolved
Priority: 0/
Queue: MIME-tools

People
Owner: Nobody in particular
Requestors: perl [...] aaroncrane.co.uk
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 5.411
Fixed in: 5.418



Subject: Missing 'local $_' in MIME::Decoder::QuotedPrint
MIME::Decoder::QuotedPrint's subs decode_it() and encode_it() assign to $_ without localizing it first. I noticed this bug in 5.411; looking at the code, it's still there in 5.417. It does seem to be fixed in the 6.200_01 developer release from 2003, but I'm not sure whether anyone's working on that code. I've attached a simple patch against 5.417 which adds failing tests, and adds 'local $_' lines where appropriate to pass the tests. -- Aaron Crane
diff -ur MIME-tools-5.417.orig/lib/MIME/Decoder/QuotedPrint.pm MIME-tools-5.417/lib/MIME/Decoder/QuotedPrint.pm --- MIME-tools-5.417.orig/lib/MIME/Decoder/QuotedPrint.pm 2005-01-13 19:23:15.000000000 +0000 +++ MIME-tools-5.417/lib/MIME/Decoder/QuotedPrint.pm 2005-03-08 13:31:26.000000000 +0000 @@ -109,6 +109,7 @@ my $init = 0; my $badpdf = 0; + local $_; while (defined($_ = $in->getline)) { # # Dirty hack to fix QP-Encoded PDFs from MS-Outlook. @@ -148,6 +149,7 @@ sub encode_it { my ($self, $in, $out, $textual_type) = @_; + local $_; while (defined($_ = $in->getline)) { $out->print(encode_qp_really($_, $textual_type)); } diff -ur MIME-tools-5.417.orig/t/Decoder.t MIME-tools-5.417/t/Decoder.t --- MIME-tools-5.417.orig/t/Decoder.t 2004-09-08 01:41:09.000000000 +0100 +++ MIME-tools-5.417/t/Decoder.t 2005-03-08 13:30:13.000000000 +0000 @@ -33,7 +33,7 @@ # Create checker: my $T = typical ExtUtils::TBone; -$T->begin(scalar(@encodings)); +$T->begin(2 * scalar(@encodings)); # Report what tests we may be skipping: $T->msg($has_gzip @@ -43,6 +43,8 @@ # Test each encoding in turn: my ($e, $eno) = (undef, 0); foreach $e (@encodings) { + my $original_dollar_underscore = 'original $_'; + local $_ = $original_dollar_underscore; ++$eno; my $decoder = MIME::Decoder->new($e); unless(defined($decoder)) { @@ -80,6 +82,9 @@ else { $T->ok(1); } + + # And check that $_ didn't get overwritten. + $T->ok(defined($_) && $_ eq $original_dollar_underscore); } # Done!