php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73110 Mails with header mime-version which end with a semicolon gets treated as plain
Submitted: 2016-09-19 06:20 UTC Modified: -
From: jochem dot blok at fasterforward dot nl Assigned:
Status: Open Package: mailparse (PECL)
PHP Version: 5.6.26 OS: Ubuntu 14.04
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jochem dot blok at fasterforward dot nl
New email:
PHP Version: OS:

 

 [2016-09-19 06:20 UTC] jochem dot blok at fasterforward dot nl
Description:
------------
We are trying to parse an e-mail with mailparse extension. The header Mime-Version is as follows: "Mime-Version: 1.0;", note the semicolon at the end. Due to this semicolon mailparse treats the mail as text/plain.

Test script:
---------------
$tekst = 'Mime-Version: 1.0;
Content-Type: multipart/Alternative; boundary="=====1473780076CSSSMTP_CLIENT=="

--=====1473780076CSSSMTP_CLIENT==
Content-Type: text/plain

Hello please pay attached invoice
--=====1473780076CSSSMTP_CLIENT==
Content-Type: text/html; charset=utf-8

Hello please pay attached invoice

--=====1473780076CSSSMTP_CLIENT==--';
$stream = fopen('php://memory', 'r+');
fwrite($stream, $tekst);
fseek($stream, 0);
$resource = mailparse_msg_create();
mailparse_msg_parse($resource, fread($stream, 10000));
$data = mailparse_msg_get_part_data(mailparse_msg_get_part($resource, 1));
print_r($data['content-type']);

Expected result:
----------------
multipart/alternative

Actual result:
--------------
text/plain

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC