Skip Menu |

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

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

People
Owner: dfs+pause [...] roaringpenguin.com
Requestors: FANY [...] cpan.org
Cc: NNIS-4986 [...] jira.noris.de
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 5.508
Fixed in: (no value)



CC: NNIS-4986 [...] jira.noris.de
Subject: MIME::Parser::parse_date() should check what it gets back from IO::File
Because that might be undef, and in that case you will get a strange error messages from MIME::Parser::Reader::native_handle() down the stack and wonder why: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $ cat mp #!/usr/bin/env perl use 5.014; use utf8; use warnings; use MIME::Parser; say "Perl version: $]"; say 'MIME::Parser version: ', MIME::Parser->VERSION; my $s = <<'_'; From: fany@cpan.org Subject: Test ☺ _ my $p = MIME::Parser->new; my $m = $p->parse_data($s); $ ./mp Perl version: 5.024000 MIME::Parser version: 5.508 Can't call method "isa" on an undefined value at /usr/local/lib/perl5/site_perl/5.24.0/MIME/Parser/Reader.pm line 186. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BTW, the reason for the failure is: fany@homer:~> perl -w mp Perl version: 5.024000 MIME::Parser version: 5.508 Strings with code points over 0xFF may not be mapped into in-memory file handles Can't call method "isa" on an undefined value at /usr/local/lib/perl5/site_perl/5.24.0/MIME/Parser/Reader.pm line 186. So I think it's OK that it doesn't work; it just should notice that a bit earlier. :-) Regards fany
Subject: Re: [rt.cpan.org #119166] MIME::Parser::parse_date() should check what it gets back from IO::File
Date: Thu, 8 Dec 2016 11:20:25 -0500
To: bug-MIME-tools [...] rt.cpan.org
From: Dianne Skoll <dfs [...] roaringpenguin.com>
Hi, Show quoted text
> So I think it's OK that it doesn't work; it just should notice that a > bit earlier. :-)
Agreed. I think this patch will do the right thing: --- a/lib/MIME/Parser.pm +++ b/lib/MIME/Parser.pm @@ -1109,6 +1109,10 @@ Returns the parsed MIME::Entity on success. sub parse_data { my ($self, $data) = @_; + if (!defined($data)) { + croak "parse_data: No data passed"; + } + ### Get data as a scalar: my $io; Regards, Dianne.
Subject: Re: [rt.cpan.org #119166] MIME::Parser::parse_date() should check what it gets back from IO::File
Date: Thu, 8 Dec 2016 11:25:52 -0500
To: bug-MIME-tools [...] rt.cpan.org
From: Dianne Skoll <dfs [...] roaringpenguin.com>
Hi again, Oops, that patch is no good. Here's a better one. Regards, Dianne. --- a/lib/MIME/Parser.pm +++ b/lib/MIME/Parser.pm @@ -1109,6 +1109,10 @@ Returns the parsed MIME::Entity on success. sub parse_data { my ($self, $data) = @_; + if (!defined($data)) { + croak "parse_data: No data passed"; + } + ### Get data as a scalar: my $io; @@ -1126,6 +1130,10 @@ sub parse_data { croak "parse_data: wrong argument ref type: ", ref($data); } + if (!$io) { + croak "parse_data: unable to open in-memory file handle"; + } + ### Parse! return $self->parse($io); }
Hi, I've released version 5.509 of MIME::tools at http://search.cpan.org/~dskoll/MIME-tools-5.509/ I believe it fixes this bug. Regards, Dianne.