From 82cb36ff3a33b5582f07ee26391391f1b3f7698c Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Mon, 7 Jun 2010 14:31:59 +0000 Subject: [PATCH] some additional stuff to improve mailheader decoding --- phpgwapi/inc/class.translation.inc.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/phpgwapi/inc/class.translation.inc.php b/phpgwapi/inc/class.translation.inc.php index 22cbc87f2b..697c00e754 100644 --- a/phpgwapi/inc/class.translation.inc.php +++ b/phpgwapi/inc/class.translation.inc.php @@ -985,17 +985,35 @@ class translation //error_log(__FILE__.','.__METHOD__.':'."called with $_string and CHARSET $displayCharset"); if(function_exists(imap_mime_header_decode)) { + // some characterreplacements, as they fail to translate + $sar = array( + '@(\x84|\x93|\x94)@', + '@(\x96|\x97)@', + '@(\x91|\x92)@', + '@(\x85)@', + '@(\x86)@', + ); + $rar = array( + '"', + '-', + '\'', + '...', + '+', + ); + $newString = ''; $string = preg_replace('/\?=\s+=\?/', '?= =?', $_string); $elements=imap_mime_header_decode($string); + $convertAtEnd = false; foreach((array)$elements as $element) { if ($element->charset == 'default') $element->charset = 'iso-8859-1'; if ($element->charset != 'x-unknown') { + if( strtoupper($element->charset) != 'UTF-8') $element->text = preg_replace($sar,$rar,$element->text); $newString .= self::convert($element->text,$element->charset); } else