Skip Menu |

This queue is for tickets about the Encode CPAN distribution.

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

People
Owner: Nobody in particular
Requestors: peter [...] makholm.net
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in:
  • 2.23
  • 2.24
  • 2.25
  • 2.26
  • 2.27
  • 2.28
  • 2.29
Fixed in: (no value)



Subject: Encode::MIME::Header::decode should respect CHECK argument
Encoded::MIME::Heade::decode handles malformed data in the content of encoded-words by silently converting them to perlqq-form. This makes error handling hard when you need to handle malformed data. Instead of hardcoding the underlying decode-call to use FB_PERLQQ this should be propagated form the encode ('MIME-Header', $string) call. The attached patch implements a compromise between being backward compatible and being compatible to the documentation in Encode.pm I'm no really sure what the "$_[1] = '' if $chk" is supposed to achive. It is contradictory to the Encode.pm documentation and not mentioned in Encode/MIME/Header.pm documentation. By using $str instead of the empty string it seems to comply with my reading of the documentation.
Subject: Encode.patch
--- /usr/lib/perl/5.10/Encode/MIME/Header.pm 2009-01-01 16:56:48.000000000 +0100 +++ /tmp/lib/Encode//MIME/Header.pm 2009-02-11 14:40:29.000000000 +0100 @@ -61,15 +61,15 @@ }{ if (uc($2) eq 'B'){ $obj->{decode_b} or croak qq(MIME "B" unsupported); - decode_b($1, $3); + decode_b($1, $3, $chk); }elsif(uc($2) eq 'Q'){ $obj->{decode_q} or croak qq(MIME "Q" unsupported); - decode_q($1, $3); + decode_q($1, $3, $chk); }else{ croak qq(MIME "$2" encoding is nonexistent!); } }egox; - $_[1] = '' if $chk; + $_[1] = $str if $chk; return $str; } @@ -77,19 +77,20 @@ my $enc = shift; my $d = find_encoding($enc) or croak qq(Unknown encoding "$enc"); my $db64 = decode_base64(shift); + my $chk = shift; return $d->name eq 'utf8' ? Encode::decode_utf8($db64) - : $d->decode( $db64, Encode::FB_PERLQQ ); + : $d->decode( $db64, $chk // Encode::FB_PERLQQ ); } sub decode_q { - my ( $enc, $q ) = @_; + my ( $enc, $q, $chk ) = @_; my $d = find_encoding($enc) or croak qq(Unknown encoding "$enc"); $q =~ s/_/ /go; $q =~ s/=([0-9A-Fa-f]{2})/pack("C", hex($1))/ego; return $d->name eq 'utf8' ? Encode::decode_utf8($q) - : $d->decode( $q, Encode::FB_PERLQQ ); + : $d->decode( $q, $chk // Encode::FB_PERLQQ ); } my $especials =
Thanks, applied in my repository. Fixed in the next version. Dan the Maintainer Thereof On Wed Feb 11 09:31:36 2009, pmakholm wrote: Show quoted text
> Encoded::MIME::Heade::decode handles malformed data in the content of > encoded-words by silently converting them to perlqq-form. This makes > error handling hard when you need to handle malformed data. > > Instead of hardcoding the underlying decode-call to use FB_PERLQQ this > should be propagated form the encode ('MIME-Header', $string) call. > > The attached patch implements a compromise between being backward > compatible and being compatible to the documentation in Encode.pm > > I'm no really sure what the "$_[1] = '' if $chk" is supposed to achive. > It is contradictory to the Encode.pm documentation and not mentioned in > Encode/MIME/Header.pm documentation. By using $str instead of the empty > string it seems to comply with my reading of the documentation.