mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-23 13:51:12 +01:00
try to fix broken UTF-8 on message display
This commit is contained in:
parent
17445482f8
commit
f95aec0328
@ -389,6 +389,30 @@
|
||||
$this->t->set_var('lang_no_subject',lang('No subject given!'));
|
||||
$this->t->pparse("out","header");
|
||||
|
||||
// prepare body
|
||||
// in a way, this tests if we are having real utf-8 (the displayCharset) by now; we should if charsets reported (or detected) are correct
|
||||
if (strtoupper($this->displayCharset) == 'UTF-8')
|
||||
{
|
||||
$test = @json_encode($sessionData['body']);
|
||||
//error_log(__METHOD__.__LINE__.' ->'.strlen($singleBodyPart['body']).' Error:'.json_last_error().'<- BodyPart:#'.$test.'#');
|
||||
//if (json_last_error() != JSON_ERROR_NONE && strlen($singleBodyPart['body'])>0)
|
||||
if ($test=="null" && strlen($sessionData['body'])>0)
|
||||
{
|
||||
// try to fix broken utf8
|
||||
$x = (function_exists('mb_convert_encoding')?mb_convert_encoding($sessionData['body'],'UTF-8','UTF-8'):(function_exists('iconv')?@iconv("UTF-8","UTF-8//IGNORE",$sessionData['body']):$sessionData['body']));
|
||||
$test = @json_encode($x);
|
||||
if ($test=="null" && strlen($sessionData['body'])>0)
|
||||
{
|
||||
// this should not be needed, unless something fails with charset detection/ wrong charset passed
|
||||
error_log(__METHOD__.__LINE__.' Charset problem detected; Charset Detected:'.felamimail_bo::detect_encoding($sessionData['body']));
|
||||
$sessionData['body'] = utf8_encode($sessionData['body']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sessionData['body'] = $x;
|
||||
}
|
||||
}
|
||||
}
|
||||
// body
|
||||
if($sessionData['mimeType'] == 'html') {
|
||||
$mode = 'simple';
|
||||
|
@ -1298,9 +1298,19 @@
|
||||
//if (json_last_error() != JSON_ERROR_NONE && strlen($singleBodyPart['body'])>0)
|
||||
if ($test=="null" && strlen($singleBodyPart['body'])>0)
|
||||
{
|
||||
// this should not be needed, unless something fails with charset detection/ wrong charset passed
|
||||
error_log(__METHOD__.__LINE__.' Charset Reported:'.$singleBodyPart['charSet'].' Carset Detected:'.bofelamimail::detect_encoding($singleBodyPart['body']));
|
||||
$singleBodyPart['body'] = utf8_encode($singleBodyPart['body']);
|
||||
// try to fix broken utf8
|
||||
$x = (function_exists('mb_convert_encoding')?mb_convert_encoding($singleBodyPart['body'],'UTF-8','UTF-8'):(function_exists('iconv')?@iconv("UTF-8","UTF-8//IGNORE",$singleBodyPart['body']):$singleBodyPart['body']));
|
||||
$test = @json_encode($x);
|
||||
if (($test=="null" || $test === false || is_null($test)) && strlen($singleBodyPart['body'])>0)
|
||||
{
|
||||
// this should not be needed, unless something fails with charset detection/ wrong charset passed
|
||||
error_log(__METHOD__.__LINE__.' Charset Reported:'.$singleBodyPart['charSet'].' Charset Detected:'.felamimail_bo::detect_encoding($singleBodyPart['body']));
|
||||
$singleBodyPart['body'] = utf8_encode($singleBodyPart['body']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$singleBodyPart['body'] = $x;
|
||||
}
|
||||
}
|
||||
}
|
||||
//error_log($singleBodyPart['body']);
|
||||
|
Loading…
Reference in New Issue
Block a user