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_mimeDecode » Bug #7676

Content-Type decoding isn't compliant with RFC 2045

Details

Submitted2006-05-20 02:22 UTC
Frompriappub at yahoo dot fr
StatusNo Feedback
PackageMail_mimeDecode
PHP Version5.1.4
OSALL
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];
}
...