PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Mail » Mail_Mime » Bug #2481

multipart not detected if enclosed in double quotes

Details

Submitted2004-10-08 05:41 UTC
Fromvik_agrawal at hotmail dot com
Assignedsean
StatusClosed
PackageMail_Mime
PHP VersionIrrelevant
OSWindows 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.