php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68821 Underscores left by mb_decode_mimeheaders
Submitted: 2015-01-13 03:47 UTC Modified: 2015-05-28 14:45 UTC
Votes:9
Avg. Score:3.9 ± 0.6
Reproduced:9 of 9 (100.0%)
Same Version:3 (33.3%)
Same OS:3 (33.3%)
From: php dot bohwaz at miam dot kd2 dot org Assigned:
Status: Verified Package: mbstring related
PHP Version: 5.4.36 OS: Debian/Linux
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: php dot bohwaz at miam dot kd2 dot org
New email:
PHP Version: OS:

 

 [2015-01-13 03:47 UTC] php dot bohwaz at miam dot kd2 dot org
Description:
------------
mb_decode_mimeheaders doesn't decode underscores as per the RFC 2047:

"The 8-bit hexadecimal value 20 (e.g., ISO-8859-1 SPACE) may be represented as "_" (underscore, ASCII 95.). (This character may not pass through some internetwork mail gateways, but its use will greatly enhance readability of "Q" encoded data with mail readers that do not support this encoding.) Note that the "_" always represents hexadecimal 20, even if the SPACE character occupies a different code position in the character set in use."

One example:

Subject: =?ISO-8859-1?Q?spring_into_ALDI_for_this_week=92s_special_buys_fr?=
 =?ISO-8859-1?Q?om_thurs_30_sep_=96_hurry,_limited_stocks_in_store?=



Test script:
---------------
<?php

$subject = "=?ISO-8859-1?Q?spring_into_ALDI_for_this_week=92s_special_buys_fr?=
 =?ISO-8859-1?Q?om_thurs_30_sep_=96_hurry,_limited_stocks_in_store?=";

echo mb_decode_mimeheaders($subject);

?>

Expected result:
----------------
spring into ALDI for this weeks special buys from thurs 30 sep  hurry, limited stocks in store

Actual result:
--------------
spring_into_ALDI_for_this_weeks_special_buys_from_thurs_30_sep__hurry,_limited_stocks_in_store

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-05-28 14:45 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2015-05-28 14:45 UTC] cmb@php.net
Verified: <http://3v4l.org/Rnt2K>. (\x92 and \x96 are undefined
for ISO-8859-1, what explains their suppression in PHP 5.6 and
HHVM. Anyhow, this is unrelated to the issue at hand.)

Apparently, the issue is with mbfl_mime_header_decode(), and
therefore should be resolved upstream in libmbfl
(<https://github.com/moriyoshi/libmbfl>).
 [2017-03-15 11:36 UTC] pudge601 at hotmail dot com
I've just run into this issue today while in the process of switching from using `iconv_mime_decode` to `mb_decode_mimeheader`.

Despite this bug being marked as verified and it being stated that this was a problem with the libmbfl, it doesn't seem like there was any issue raised against that library, so I've raised one just now: (https://github.com/moriyoshi/libmbfl/issues/25).

In the meantime, I'm using this workaround;

$header = preg_replace_callback('/(=\?[^\?]+\?Q\?)([^\?]+)(\?=)/i', function($matches) {
    return $matches[1] . str_replace('_', '=20', $matches[2]) . $matches[3];
}, $header);

Posted here in case anybody else finds this useful.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 17:01:29 2024 UTC