Re: [PEAR-BUG] Bug #17959 [NEW]: Boundaries ending with non-word characters are ignored
[email protected] (Alex Adriaanse)
| Newsgroups | php.pear.qa |
|---|---|
| Message-ID | <[email protected]> |
Alan, Sorry for the delayed response - just returned from vacation. On 10/20/2010 1:26 AM, Alan Knowles wrote: > Alex, the bug system is playing up, so I'm can't update a response. Yeah, for some reason it won't let me validate my email address/account, and consequently this bug has since been deleted. Unfortunately, I don't think I'm able to open a new bug report without this issue being fixed. > boundary split should split on the boundary string, followed by a line > break. - Can you > add a full email example where this problem occurs, either to this bug > report, or create a new one. I have attached a sample email, with some sensitive parts removed. I also created a simple patch that fixes the problem and attached it (I was going to attach it to the original bug report, but couldn't due to the problems mentioned above). Thanks, Alex
Mail_mimeDecode_testcase.txt
(text/plain, 821 B)
From: [email protected] Subject: To: [email protected] Date: Fri, 1 Oct 2010 11:35:55 -0500 Message-Id: <[email protected]> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="DC_BOUND_PRE_<1285950955.0000748f8b85>" This is a multi-part message in MIME format. --DC_BOUND_PRE_<1285950955.0000748f8b85> Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit This E-mail was sent from "**********" (******). Scan Date: 01.10.2010 11:35:55 (-0500) Queries to: *******@**.com --DC_BOUND_PRE_<1285950955.0000748f8b85> Content-Type: application/pdf; name="20101001113555392.pdf" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="20101001113555392.pdf" [File contents removed] --DC_BOUND_PRE_<1285950955.0000748f8b85>--
Mail_mimeDecode.patch
(text/plain, 479 B)
--- Mail/mimeDecode.php.orig 2010-09-28 17:41:12.000000000 -0500
+++ Mail/mimeDecode.php 2010-10-08 17:57:41.000000000 -0500
@@ -658,7 +658,7 @@
$boundary = $bs_possible;
}
- $tmp = preg_split("/--".preg_quote($boundary, '/')."(\b|--)/", $input);
+ $tmp = preg_split("/--".preg_quote($boundary, '/')."((?=\s)|--)/", $input);
$len = count($tmp) -1;
for ($i = 1; $i < $len; $i++) {
if (strlen(trim($tmp[$i]))) {