Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.5.6

Bug #9616 Failure to parse [file]name*0=x; [file]name*1=x
Submitted: 2006-12-14 17:54 UTC
From: l0c4lh0st dot nl at gmail dot com Assigned: alan_k
Status: Closed Package: Mail_mimeDecode
PHP Version: 5.1.2 OS: Windows
Roadmaps: 1.6.0    
Subscription  
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes. If this is not your bug, you can add a comment by following this link. If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
2010-09-02 17:47 UTC
Package:
Bug Type:
Summary:
From: l0c4lh0st dot nl at gmail dot com
New email:
PHP Version: Package Version: OS:

 

 [2006-12-14 17:54 UTC] l0c4lh0st dot nl at gmail dot com (l0c4lh0st)
Description: ------------ When parsing the headers, it fails to recognize the filename*0=x; filename*1=blah; filename*2=blah; (I assume this is used because of long filenames, the filename I had was pretty long). Anyway, you get the seperate parts (the means, filename*0, filename*1 etc. etc.). With the fix below you get the full filename. Test script: --------------- <?php /* (It's kinda nasty, but does the trick.) */ // This splits on a semi-colon, if there's no preceeding backslash // Now works with quoted values; had to glue the \; breaks in PHP // the regex is already bordering on incomprehensible $splitRegex = '/([^;\'"]*[\'"]([^\'"]*([^\'"]*)*)[\'"][^;\'"]*|([^;]+))(;|$)/'; preg_match_all($splitRegex, $input, $matches); /* Start fix. */ if (preg_match('/^([^\*]+)\*0\=/is', $matches[0][0], $aMatches)) { $matches[0] = array($aMatches[1] . '=' . implode('', $matches[2])); } /* End fix. */ ?> Expected result: ---------------- stdClass Object ( [headers] => Array ( [content-type] => image/jpeg; name*0="verylongfilenamegoeshereblabla.jpg" [content-transfer-encoding] => base64 [content-id] => <xxxxxxxxxxx@gmail.com> [content-disposition] => inline; filename*0="verylongfilenamegoeshereblabla"; filename*1=".jpg" ) [ctype_primary] => image [ctype_secondary] => jpeg [ctype_parameters] => Array ( [name] => verylongfilenamegoeshereblabla.jpg ) [disposition] => inline [d_parameters] => Array ( [filename] => verylongfilenamegoeshereblabla.jpg ) ) Actual result: -------------- stdClass Object ( [headers] => Array ( [content-type] => image/jpeg; name*0="verylongfilenamegoeshereblabla.jpg" [content-transfer-encoding] => base64 [content-id] => <xxxxxxxxxxx@gmail.com> [content-disposition] => inline; filename*0="verylongfilenamegoeshereblabla"; filename*1=".jpg" ) [ctype_primary] => image [ctype_secondary] => jpeg [ctype_parameters] => Array ( [name*0] => verylongfilenamegoeshereblabla.jpg ) [disposition] => inline [d_parameters] => Array ( [filename*0] => verylongfilenamegoeshereblabla [filename*1] => .jpg ) )

Comments

 [2010-09-02 17:47 UTC] alan_k (Alan Knowles)
-Status: Analyzed +Status: Closed -Assigned To: +Assigned To: alan_k
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.