From be212f908cb5d2a0e3eb901d0f151ee56c40801c Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 29 Mar 2019 16:50:33 +0100 Subject: [PATCH] * Mail: check non-utf8 body, if it might be utf-8, to display readable --- mail/inc/class.mail_ui.inc.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index 47a3e2fd69..1675b29ecd 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -3340,7 +3340,15 @@ $filter['before']= date("d-M-Y", $cutoffdate2); if(($singleBodyPart['mimeType'] == 'text/html' || $singleBodyPart['mimeType'] == 'text/plain') && strtoupper($singleBodyPart['charSet']) != 'UTF-8') { - $singleBodyPart['body'] = preg_replace($sar,$rar,$singleBodyPart['body']); + // check if client set a wrong charset and content is utf-8 --> use utf-8 + if (preg_match('//u', $singleBodyPart['body'])) + { + $singleBodyPart['charSet'] = 'UTF-8'; + } + else + { + $singleBodyPart['body'] = preg_replace($sar,$rar,$singleBodyPart['body']); + } } //error_log(__METHOD__.__LINE__.'reports:'.$singleBodyPart['charSet']); if ($singleBodyPart['charSet']=='us-ascii')