From b8e230190fc339037c21d5666c187e29ac46cdf9 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 3 May 2018 11:01:08 +0200 Subject: [PATCH] * Mail: fixed equal signs (=) are not displayed in subject Not sure why, but equal sign was removed unconditional together with other non-printable chars. Equal sign is now removed from that preg and code is cleaned up to have a single preg removing unprintable chars independet on the function used to decode the header. --- api/src/Mail/Html.php | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/api/src/Mail/Html.php b/api/src/Mail/Html.php index da21cec126..8103ed4eb6 100644 --- a/api/src/Mail/Html.php +++ b/api/src/Mail/Html.php @@ -56,13 +56,10 @@ class Html '+', ); - $newString = ''; - - $string = preg_replace('/\?=\s+=\?/', '?= =?', $_string); - - $elements=imap_mime_header_decode($string); + $elements = imap_mime_header_decode(preg_replace('/\?=\s+=\?/', '?= =?', $_string)); $convertAtEnd = false; + $string = ''; foreach((array)$elements as $element) { if ($element->charset == 'default') $element->charset = Api\Translation::detect_encoding($element->text); @@ -76,16 +73,15 @@ class Html $element->text = self::decodeMailHeader($element->text, $element->charset, $reclevel); $element->charset = $displayCharset; } - $newString .= Api\Translation::convert($element->text,$element->charset); + $string .= Api\Translation::convert($element->text,$element->charset); } else { - $newString .= $element->text; + $string .= $element->text; $convertAtEnd = true; } } - if ($convertAtEnd) $newString = self::decodeMailHeader($newString,$displayCharset,$reclevel); - return preg_replace('/([\000-\012\015\016\020-\037\075])/','',$newString); + if ($convertAtEnd) $string = self::decodeMailHeader($string, $displayCharset, $reclevel); } elseif(function_exists(mb_decode_mimeheader)) { @@ -101,17 +97,19 @@ class Html str_replace('=?windows-1258','=?ISO-8859-1',$string)); } $string = mb_decode_mimeheader($string); - return preg_replace('/([\000-\012\015\016\020-\037\075])/','',$string); } elseif(function_exists(iconv_mime_decode)) { // continue decoding also if an error occurs $string = @iconv_mime_decode($_string, 2, $displayCharset); - return preg_replace('/([\000-\012\015\016\020-\037\075])/','',$string); } - - // no decoding function available - return preg_replace('/([\000-\012\015\016\020-\037\075])/','',$_string); + else + { + // no decoding function available + $string = $_string; + } + // remove unprintable chars + return preg_replace('/([\000-\012\015\016\020-\037])/', '', $string); } /**