Re: Fwd: Re: Email::MIME walk_parts doesn't walk all my parts

2010-09-06 Thread Ricardo Signes
* Erik Logtenberg  [2010-08-29T17:26:38]
> Since this change, inspired by Ricardo Signes, fixes an obvious bug in
> Email::MIME, I'd like to request this patch be pushed into git. Also a
> new release of Email::MIME containing this fix would be nice.

Released in 1.905, thanks!


-- 
rjbs


Fwd: Re: Email::MIME walk_parts doesn't walk all my parts

2010-08-29 Thread Erik Logtenberg
Hi,

Since this change, inspired by Ricardo Signes, fixes an obvious bug in
Email::MIME, I'd like to request this patch be pushed into git. Also a
new release of Email::MIME containing this fix would be nice.

Kind regards,

Erik.


 Original Message 
Subject: Re: Email::MIME walk_parts doesn't walk all my parts
Date: Thu, 03 Jun 2010 23:43:24 +0200
From: Erik Logtenberg 
To: pep@perl.org

> This looks like an incredibly stupid bug based on the incredibly stupid 
> ->parts
> method.  Its behavior is really lame.
> 
> I'm afraid I don't have a lot more time to look at this right now, but I'd 
> play
> around with tweaking walk_parts (in Email::MIME) to use ->subparts instead,
> which is a lot saner.
> 
> If that fixes this, it's probably a welcome patch.  Thanks for the report.

Yeah that fixes this indeed, thank you very much. Please find attached
the patch to MIME.pm with this fix.

Kind regards,

Erik.

--- Email/MIME.pm-orig	2009-12-23 17:35:11.0 +0100
+++ Email/MIME.pm	2010-06-03 23:39:39.334928669 +0200
@@ -712,9 +712,9 @@
   $walk = sub {
 my ($part) = @_;
 $callback->($part);
-if ($part->parts > 1) {
+if ($part->subparts > 0) {
   my @subparts;
-  for ($part->parts) {
+  for ($part->subparts) {
 push @subparts, $walk->($_);
   }
   $part->parts_set(\...@subparts);



Re: Email::MIME walk_parts doesn't walk all my parts

2010-06-03 Thread Erik Logtenberg
> This looks like an incredibly stupid bug based on the incredibly stupid 
> ->parts
> method.  Its behavior is really lame.
> 
> I'm afraid I don't have a lot more time to look at this right now, but I'd 
> play
> around with tweaking walk_parts (in Email::MIME) to use ->subparts instead,
> which is a lot saner.
> 
> If that fixes this, it's probably a welcome patch.  Thanks for the report.

Yeah that fixes this indeed, thank you very much. Please find attached
the patch to MIME.pm with this fix.

Kind regards,

Erik.
--- Email/MIME.pm-orig	2009-12-23 17:35:11.0 +0100
+++ Email/MIME.pm	2010-06-03 23:39:39.334928669 +0200
@@ -712,9 +712,9 @@
   $walk = sub {
 my ($part) = @_;
 $callback->($part);
-if ($part->parts > 1) {
+if ($part->subparts > 0) {
   my @subparts;
-  for ($part->parts) {
+  for ($part->subparts) {
 push @subparts, $walk->($_);
   }
   $part->parts_set(\...@subparts);


Re: Email::MIME walk_parts doesn't walk all my parts

2010-06-03 Thread Ricardo Signes
* Erik Logtenberg  [2010-06-03T14:23:52]
> $email->walk_parts(sub {
> my ($part) = @_;
> warn($part->content_type . ": " . $part->parts);
> });
> 
> This little snippet is supposed to read an email from stdin and print
> the content-types of all parts (plus the amount of subparts that it has).
> 
> Now for most emails this works fine, but not so for attached email. For
> this email it only sees the first part:

This looks like an incredibly stupid bug based on the incredibly stupid ->parts
method.  Its behavior is really lame.

I'm afraid I don't have a lot more time to look at this right now, but I'd play
around with tweaking walk_parts (in Email::MIME) to use ->subparts instead,
which is a lot saner.

If that fixes this, it's probably a welcome patch.  Thanks for the report.

-- 
rjbs


Email::MIME walk_parts doesn't walk all my parts

2010-06-03 Thread Erik Logtenberg
Hi,

I'm using Email::MIME to iterate through all parts of a multipart email,
with the following code, which I have somewhat copied from the manual
Email::MIME manual.

use Email::MIME;
my $email;
{
local $/;
$email = Email::MIME->new();
}

$email->walk_parts(sub {
my ($part) = @_;
warn($part->content_type . ": " . $part->parts);
});

This little snippet is supposed to read an email from stdin and print
the content-types of all parts (plus the amount of subparts that it has).

Now for most emails this works fine, but not so for attached email. For
this email it only sees the first part:

multipart/mixed;  boundary="=_Part_13986_26026450.1275360964578": 1

I would expect walk_parts to also iterate through the multipart/related,
text/html and image/gif parts, but it does not.

It may very well be that this email is malformed in some way, but this
is the way I received it (I erased most of the actual content to make it
shorter but the result is the same). Thunderbird has no problem parsing
it, but perhaps Tbird is somewhat tolerant.

Kind regards,

Erik.


P.S. I use the latest version of Email::MIME from CPAN and also the
latest versions of the following dependencies:
Email::Address
Email::MessageID
Email::MIME::ContentType
Email::MIME::Creator
Email::MIME::Encodings
Email::MIME::Header
Email::MIME::Modifier
Email::Simple::Creator

Perl itself and all other dependencies that may be are from Fedora 12
x86_64.


email3.eml
Description: application/mimearchive