Home » Mail » Mail_Mime » Bug #2481
multipart not detected if enclosed in double quotes
Details
| Submitted | 2004-10-08 05:41 UTC |
|---|---|
| From | vik_agrawal at hotmail dot com |
| Assigned | sean |
| Status | Closed |
| Package | Mail_Mime |
| PHP Version | Irrelevant |
| OS | Windows XP |
| Roadmaps | (Not assigned) |
Comments
[2004-10-08 05:41 UTC] vik_agrawal at hotmail dot com
Description:
------------
The function in mimeDecode.php of Mail_Mime-1.2.1 pear classes
function _parseHeaderValue($input)
{
if (($pos = strpos($input, ';')) !== false) {
$return['value'] = trim(substr($input, 0, $pos));
$input = trim(substr($input, $pos+1));
if (strlen($input) > 0) {
// This splits on a semi-colon, if there's no preceeding backslash
// Can't handle if it's in double quotes however. (Of course anyone
// sending that needs a good slap).
$parameters = preg_split('/\s*(?<!\\\\);\s*/i', $input);
for ($i = 0; $i < count($parameters); $i++) {
$param_name = substr($parameters[$i], 0, $pos = strpos($parameters[$i], '='));
$param_value = substr($parameters[$i], $pos + 1);
if ($param_value[0] == '"') {
$param_value = substr($param_value, 1, -1);
}
$return['other'][$param_name] = $param_value;
$return['other'][strtolower($param_name)] = $param_value;
}
}
} else {
$return['value'] = trim($input);
}
return $return;
}
do not resolve multipart in the content-type header of email body if the multipart is enclosed in double quotes for example:
Content-Type: multipart/related;
type="multipart/alternative";
boundary="----=_NextPart_000_002F_01C4AB07.C075C180"
for solution
change the function to
function _parseHeaderValue($input)
{
if (($pos = strpos($input, ';')) !== false) {
$return['value'] = trim(substr($input, 0, $pos));
$input = trim(substr($input, $pos+1));
if(eregi("content-type", $input))
{
$input = str_replace("\"", "", $input);
}
if (strlen($input) > 0) {
// This splits on a semi-colon, if there's no preceeding backslash
// Can't handle if it's in double quotes however. (Of course anyone
// sending that needs a good slap).
$parameters = preg_split('/\s*(?<!\\\\);\s*/i', $input);
for ($i = 0; $i < count($parameters); $i++) {
$param_name = substr($parameters[$i], 0, $pos = strpos($parameters[$i], '='));
$param_value = substr($parameters[$i], $pos + 1);
if ($param_value[0] == '"') {
$param_value = substr($param_value, 1, -1);
}
$return['other'][$param_name] = $param_value;
$return['other'][strtolower($param_name)] = $param_value;
}
}
} else {
$return['value'] = trim($input);
}
return $return;
}
or do some changes in
if ($param_value[0] == '"') {
$param_value = substr($param_value, 1, -1);
}
[2004-10-08 05:45 UTC] vik_agrawal at hotmail dot com
no comment. just changed the title.