Home » Mail » Mail_mimeDecode » Bug #7676
Content-Type decoding isn't compliant with RFC 2045
Details
| Submitted | 2006-05-20 02:22 UTC |
|---|---|
| From | priappub at yahoo dot fr |
| Status | No Feedback |
| Package | Mail_mimeDecode |
| PHP Version | 5.1.4 |
| OS | ALL |
| Roadmaps | (Not assigned) |
Comments
[2006-05-20 02:22 UTC] priappub at yahoo dot fr
Description:
------------
The RFC 2045 says:
"Default RFC 822 messages without a MIME Content-Type
header are taken by this protocol to be plain text in the
US-ASCII character set, which can be explicitly specified
as:
Content-type: text/plain; charset=us-ascii
This default is assumed if no Content-Type header field is
specified. It is also recommend that this default be
assumed when a syntactically invalid Content-Type header
field is encountered."
In function _decode, if there is no Content-Type, it's OK,
we have:
$ctype = explode('/', $default_ctype);
$return->ctype_primary = $ctype[0];
$return->ctype_secondary = $ctype[1];
But if we have "Content-Type: text" which is not RFC
compliant, we haven't this piece of code and
ctype_secondary isn't defined.
[2006-05-20 02:56 UTC] priappub at yahoo dot fr
The RFC 2045 says:
"Default RFC 822 messages without a MIME Content-Type
header are taken by this protocol to be plain text in the
US-ASCII character set, which can be explicitly specified
as:
Content-type: text/plain; charset=us-ascii
This default is assumed if no Content-Type header field is
specified. It is also recommend that this default be
assumed when a syntactically invalid Content-Type header
field is encountered."
In function _decode, if there is no Content-Type, it's OK,
we have:
$ctype = explode('/', $default_ctype);
$return->ctype_primary = $ctype[0];
$return->ctype_secondary = $ctype[1];
But if we have for exemple "Content-Type: text" which is not RFC compliant, we haven't this piece of code. ctype_primary and ctype_secondary are not defined.
I suggest on line 318:
default:
$ctype = explode('/', $default_ctype);
$return->ctype_primary = $ctype[0];
$return->ctype_secondary = $ctype[1];
...
[2006-05-20 03:09 UTC] priappub at yahoo dot fr
I have no brain, it's on line 245:
if (preg_match('/([0-9a-z+.-]+)\/([0-9a-z+.-]+)/i',
$content_type['value'], $regs)) {
$return->ctype_primary = $regs[1];
$return->ctype_secondary = $regs[2];
}
// Content type != type "/" subtype
else {
$ctype = explode('/', $default_ctype);
$return->ctype_primary = $ctype[0];
$return->ctype_secondary = $ctype[1];
}
...