Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Email-MIME-Attachment-Stripper CPAN distribution.

Report information
The Basics
Id: 20536
Status: resolved
Priority: 0/
Queue: Email-MIME-Attachment-Stripper

Owner: Nobody in particular
Requestors: DROLSKY [...]

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

Subject: Nested multipart messages are not handled correctly (I think)
Ok, I haven't actually tested this, but I think this is true from reading the code. Basically, the module seems to assume that you're always stripping attachments from relatively flat structure, basically a message where the main content type is multipart/mixed, and it contains a text/plain body and then some attachments. I think that if it were given a more complex structure it would produce some weird results. Imagine the following: multipart/mixed | |-- multipart/alternative | | | |-- text/plain | | | |-- text/html | |-- application/pdf I think that in this case the multipart/alternative part would be considered an attachment, which is not a good thing. I think the fix for this is to make sure that the content-disposition header matches /attachment/, not just that it _doesn't_ match /inline/. Of course, this means that the part in question would be entirely thrown away, but I think that's okay, as this module seems to be designed to be destructive of the original structure.
From: sartak [...]
Download (untitled) / with headers
text/plain 254b
I'm seeing this bug as well. It causes Hiveminder to lose attachments on forwarded messages (particularly from gmail). Attached is a copy of an email that does not have its attachment correctly detected, if you're in need. :) Shawn for Best Practical
Download forward.txt
text/plain 850b
From: Sartak <> Subject: Fwd: This is a banana MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_347_2143023.1212112482563" ------=_Part_347_2143023.1212112482563 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline ---------- Forwarded message ---------- From: Sartak <> Date: May 29, 2008 9:53 PM Subject: This is a banana To:, Peel it before you enjoy. ------=_Part_347_2143023.1212112482563 Content-Type: application/octet-stream; Content-Transfer-Encoding: base64 X-Attachment-Id: f_fgu4erjf Content-Disposition: attachment; IyEvdXNyL2Jpbi9lbnYgcGVybAp1c2Ugc3RyaWN0Owp1c2Ugd2FybmluZ3M7CgpkaWUgImJhbmFu YVxuIjsKCg== ------=_Part_347_2143023.1212112482563--
From: dougbitcard [...]
Download (untitled) / with headers
text/plain 413b
In this rather common case: Show quoted text
> multipart/mixed > | > |-- multipart/alternative > | | > | |-- text/plain > | | > | |-- text/html > | > |-- application/pdf
The problem is th t the code recurses into the multi-part, finds the plain text, and drops it on the return. There's a pretty simple fix: return that part from the recursive call. I've attached a diff -c/patch file.
Download Stripper.patch
text/x-diff 889b
*** 2008-06-26 13:30:39.000000000 -0700 --- 2008-06-26 13:41:11.000000000 -0700 *************** *** 121,127 **** push(@keep, $_) and next if $ct =~ m[text/plain]i && $dp =~ /inline/i; push @attach, $_; ! $self->_detach_all($_) if $_->parts > 1; } $part->parts_set(\@keep); push @{$self->{attach}}, map { --- 121,130 ---- push(@keep, $_) and next if $ct =~ m[text/plain]i && $dp =~ /inline/i; push @attach, $_; ! if ($_->parts > 1) { ! my @kept=$self->_detach_all($_); ! push(@keep,@kept) if @kept; ! } } $part->parts_set(\@keep); push @{$self->{attach}}, map { *************** *** 137,142 **** --- 140,147 ---- : ($_->filename || ''), } } @attach; + + return @keep; } 1;
fixed in 1.315 thanks, all -- rjbs

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to