Bug #9616 [Ana->Csd]: Failure to parse [file]name*0=x; [file]name*1=x

From: Date: Thu, 02 Sep 2010 13:47:44 +0000
Subject: Bug #9616 [Ana->Csd]: Failure to parse [file]name*0=x; [file]name*1=x
References: 1  Groups: php.pear.bugs 
Request: Send a blank email to pear-bugs+get-4747@lists.php.net to get a copy of this message
Edit report at http://pear.php.net/bugs/bug.php?id=9616&edit=1 ID: 9616 Updated by: alan@akbkhome.com Reported By: l0c4lh0st dot nl at gmail dot com Summary: Failure to parse [file]name*0=x; [file]name*1=x -Status: Analyzed +Status: Closed Type: Bug Package: Mail_mimeDecode Operating System: Windows PHP Version: 5.1.2 -Assigned To: +Assigned To: alan_k Roadmap Versions: New Comment: -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. Previous Comments: ------------------------------------------------------------------------ [2006-12-14 12:54:50] l0c4lh0st dot nl at gmail dot com 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 ) ) ------------------------------------------------------------------------ -- Edit this bug report at http://pear.php.net/bugs/bug.php?id=9616&edit=1

« previous php.pear.bugs (#4747) next »