Bug #68821 [Com]: Underscores left by mb_decode_mimeheaders

From: Date: Wed, 15 Mar 2017 11:36:22 +0000
Subject: Bug #68821 [Com]: Underscores left by mb_decode_mimeheaders
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207850@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68821&edit=1 ID: 68821 Comment by: pudge601 at hotmail dot com Reported by: php dot bohwaz at miam dot kd2 dot org Summary: Underscores left by mb_decode_mimeheaders Status: Verified Type: Bug Package: mbstring related Operating System: Debian/Linux PHP Version: 5.4.36 Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2015-05-28 14:45:51] 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>). ------------------------------------------------------------------------ [2015-01-13 03:47:59] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=68821&edit=1

« previous php.bugs (#207850) next »