Skip to content

Commit

Permalink
If other charset than utf-8 is wrongly reported, use utf-8
Browse files Browse the repository at this point in the history
  • Loading branch information
asig2016 committed Apr 1, 2019
1 parent f208af8 commit eba66e8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions api/src/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -1699,6 +1699,11 @@ function getHeaders($_folderName, $_startMessage, $_numberOfMessages, $_sort, $_
$this->fetchPartContents($uid, $_structure, false,true);
$headerObject['BODYPREVIEW']=trim(str_replace(array("\r\n","\r","\n"),' ',mb_substr(Mail\Html::convertHTMLToText($_structure->getContents()),0,((int)$_fetchPreviews<300?300:$_fetchPreviews))));
$charSet = $part->getCharset();
// check if client set a wrong charset and content is utf-8 --> use utf-8
if (strtolower($charSet) !='utf-8' && preg_match('//u', $headerObject['BODYPREVIEW']))
{
$charSet['charSet'] = 'UTF-8';
}
// add line breaks to $bodyParts
//error_log(__METHOD__.' ('.__LINE__.') '.' Charset:'.$bodyParts[$i]['charSet'].'->'.$bodyParts[$i]['body']);
$headerObject['BODYPREVIEW'] = Translation::convert_jsonsafe($headerObject['BODYPREVIEW'], $charSet);
Expand Down

0 comments on commit eba66e8

Please sign in to comment.