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  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 21 + 50 = ?

 
 [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] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!