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

Bug #9616 Failure to parse [file]name*0=x; [file]name*1=x
Submitted: 2006-12-14 12:54 UTC Modified: 2007-02-12 16:20 UTC
From: l0c4lh0st dot nl at gmail dot com Assigned:
Status: Analyzed 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:
Package:
Bug Type:
Summary:
From: l0c4lh0st dot nl at gmail dot com
New email:
PHP Version: Package Version: OS:

 

 [2006-12-14 12: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