Subject: | MIME:Parser doesn't check if a content-decoder is supported before create a new MIME::Decoder object |
When parsing a mail containing a not supported value in
Content-Transfer-Encoding header, on process_singlepart subroutine,
MIME::Decoder, returns an error. We should be sure content-decoder value
is supported before create a new MIME::Decoder object.
Example error: "no decoder for iso-8859-1 at .../cpan-lib/MIME/Parser.pm
line 821"
I just added as a patch my workaround about it.
Perl v 5.10.0
OpenSuSe 11.2
HTH
Thanks,
Carlos Garcia
Subject: | MIME-Parse_patch.txt |
Just the patch for the Parser.pm:
===================================================================
--- Parser.pm 28 Jun 2010 14:00:10 -0000
+++ Parser.pm 6 Jan 2011 21:02:00 -0000
@@ -818,15 +818,14 @@
### Get a content-decoder to decode this part's encoding:
my $encoding = $head->mime_encoding;
- my $decoder = new MIME::Decoder $encoding;
- if (!$decoder) {
- $self->whine("Unsupported encoding '$encoding': using 'binary'... \n".
- "The entity will have an effective MIME type of \n".
- "application/octet-stream."); ### as per RFC-2045
- $ent->effective_type('application/octet-stream');
- $decoder = new MIME::Decoder 'binary';
- $encoding = 'binary';
+ if ( ! supported MIME::Decoder $encoding ){
+ $self->whine("Unsupported encoding '$encoding': using 'binary'... \n".
+ "The entity will have an effective MIME type of \n".
+ "application/octet-stream."); ### as per RFC-2045
+ $ent->effective_type('application/octet-stream');
+ $encoding = 'binary';
}
+ my $decoder = new MIME::Decoder $encoding;
### Data should be stored encoded / as-is?
if ( !$self->decode_bodies ) {