mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-27 10:23:28 +01:00
handle problem with displaying content on reply when charset reported on content does not match charset found; the result is not nice, as assumedly somehow encoding failed in the first place
This commit is contained in:
parent
9c0fc7c2c4
commit
5486b8a03f
@ -327,7 +327,7 @@
|
||||
$bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>";
|
||||
}
|
||||
if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = felamimail_bo::detect_encoding($bodyParts[$i]['body']);
|
||||
$bodyParts[$i]['body'] = $GLOBALS['egw']->translation->convert($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
|
||||
$bodyParts[$i]['body'] = translation::convert($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
|
||||
#error_log( "GetDraftData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
|
||||
$this->sessionData['body'] .= ($i>0?"<br>":""). $bodyParts[$i]['body'] ;
|
||||
}
|
||||
@ -340,7 +340,7 @@
|
||||
$this->sessionData['body'] .= "<hr>";
|
||||
}
|
||||
if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = felamimail_bo::detect_encoding($bodyParts[$i]['body']);
|
||||
$bodyParts[$i]['body'] = $GLOBALS['egw']->translation->convert($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
|
||||
$bodyParts[$i]['body'] = translation::convert($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
|
||||
#error_log( "GetDraftData (Plain) CharSet".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
|
||||
$this->sessionData['body'] .= ($i>0?"\r\n":""). $bodyParts[$i]['body'] ;
|
||||
}
|
||||
@ -612,7 +612,8 @@
|
||||
$bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>";
|
||||
}
|
||||
if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = felamimail_bo::detect_encoding($bodyParts[$i]['body']);
|
||||
$this->sessionData['body'] .= "<br>".self::_getCleanHTML($GLOBALS['egw']->translation->convert($bodyParts[$i]['body'], $bodyParts[$i]['charSet']));
|
||||
|
||||
$this->sessionData['body'] .= "<br>".self::_getCleanHTML(translation::convert($bodyParts[$i]['body'], $bodyParts[$i]['charSet']));
|
||||
#error_log( "GetReplyData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
|
||||
|
||||
}
|
||||
@ -635,7 +636,7 @@
|
||||
|
||||
// add line breaks to $bodyParts
|
||||
if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = felamimail_bo::detect_encoding($bodyParts[$i]['body']);
|
||||
$newBody = $GLOBALS['egw']->translation->convert($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
|
||||
$newBody = translation::convert($bodyParts[$i]['body'], $bodyParts[$i]['charSet']);
|
||||
#error_log( "GetReplyData (Plain) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1'));
|
||||
|
||||
$newBody = explode("\n",$newBody);
|
||||
|
@ -587,6 +587,20 @@
|
||||
$sessionData['body'] = $before.($sessionData['mimeType'] == 'html'?$sigText:$this->bocompose->convertHTMLToText($sigText)).$inbetween.$sessionData['body'];
|
||||
}
|
||||
// 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)
|
||||
{
|
||||
// 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']);
|
||||
}
|
||||
}
|
||||
|
||||
if($sessionData['mimeType'] == 'html') {
|
||||
$mode = 'simple-withimage';
|
||||
#if (isset($GLOBALS['egw_info']['server']['enabled_spellcheck'])) $mode = 'egw_simple_spellcheck';
|
||||
|
Loading…
Reference in New Issue
Block a user