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

[email protected] (Erik Logtenberg) Thu, 03 Jun 2010 23:43:24 +0200
Newsgroups perl.pep
Message-ID <[email protected]>
> 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.
fix-walk_parts.patch (text/x-patch, 422 B)
--- Email/MIME.pm-orig	2009-12-23 17:35:11.000000000 +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);