Mail_Mime doesn't decode multi-part headers?
| From: | Eric | Date: | Sat, 28 Jun 2003 20:12:52 +0000 |
| Subject: | Mail_Mime doesn't decode multi-part headers? | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-17827@lists.php.net to get a copy of this message | ||
Let me start off by saying that i'm new to this whole MIME thing. I'm
writing an abuse incident tracking application, and as such, i'm receiving
MIME encoded emails with all sorts of bizarre content (technically bizarre
and just plain bizarre). Now... most of them work fine.. but naturally,
in my testing, I happend to pick a particular message that has something
odd in it.
Here are the relevant excerpts from this particular message:
--- start of message
<***headers removed to protect the innocent***>
Subject: Fwd: These actually enjoy this
Mime-Version: 1.0
Content-Type: multipart/related;
type="multipart/alternative";
boundary="=====================_688229==.REL"
Status: RO
--=====================_688229==.REL
Content-Type: multipart/alternative;
boundary="=====================_688229==.ALT"
--=====================_688229==.ALT
Content-Type: text/plain; charset="us-ascii"; format=flowed
I did not ask for this spam and feel violated that you have abused my
<***text of mime part removed***>
thanks... thomas
--=====================_688229==.ALT--
--=====================_688229==.REL
Content-Type: image/jpeg; name="a7e8e.jpg";
x-mac-type="4A504547"; x-mac-creator="4A565752"
Content-ID: <5.2.1.1.0.20030628172127.011e52e8@pop.netspace.net.au.0>
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename="a7e8e.jpg"
/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
<***text of mime-part removed***>
urPTgmoxV1suj/zP/9k=
--=====================_688229==.REL
Content-Type: image/jpeg; name="a7f89.jpg";
x-mac-type="4A504547"; x-mac-creator="4A565752"
Content-ID: <5.2.1.1.0.20030628172127.011e52e8@pop.netspace.net.au.2>
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename="a7f89.jpg"
/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
<***text of mime-part removed***>
/wDav9q/6d9h/s28/r9rMZ//2Q==
--=====================_688229==.REL--
--- end of message
It looks like the headers themselves are encoded in a mime message part.
Mail_mimeDeode decodes the parts that use the ".ALT" boundary, but not the
parts using the ".REL" boundary.
From what I saw in the source to Mail_mimeDecode::_decode() and
::parseHeaders(), it looks like it's "accidentally" picking up the
second content-type header, and it's picking up the mime boundary as a
header as well. $content_type is not an array, and so it's just using the
last content-type header that is in the message.
Here's the relevant output from print_r():
[subject] => Fwd: These actually enjoy this
[mime-version] => 1.0
[content-type] => Array
(
[0] => multipart/related; type="multipart/alternative";
boundary="=====================_688229==.REL"
[1] => multipart/alternative;
boundary="=====================_688229==.ALT"
)
[status] => RO
[] => -=====================_688229==.REL
So there's really two things here. After a boundary is defined in the
header, should the headers be parsed through decode(), then reparse each
mime-part of the header through parseHeaders()?
Once that is done, you'll have to use each 'content-type' definition to
decode the message so you'll get all of the parts.
I don't have time to work on this since i'm on a deadline with the abuse
tracking app. Does someone have the time to fix this? I can probably get
some work done on it after I've completed my existing project.
Thanks,
Eric