January 05, 2004

Pear MIME Decode Bug

I think I discovered and killed a bug in PHP's Pear MIME Decode code.

Basically the main problem is in the way it grabs the boundary strings out of the header. It needs a couple of trim()s in order to work properly if there are spaces around the boundary entries.

In _parseHeaderValue, it needs to look like this:

for ($i = 0; $i < count($parameters); $i++) {
$param_name = substr($parameters[$i], 0, $pos = strpos($parameters[$i], '=\
'));
// erowid
$param_name = trim($param_name);
$param_value = substr($parameters[$i], $pos + 1);
// erowid
$param_value = trim($param_value);

if ($param_value[0] == '"') {
$param_value = substr($param_value, 1, -1);
}

Posted by Earth at January 5, 2004 07:55 AM
Comments
Post a comment