-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mail, fix sneak preview encoding #70
Mail, fix sneak preview encoding #70
Conversation
@@ -403,7 +403,7 @@ static function convertHTMLToText($_html,$displayCharset=false,$stripcrl=false,$ | |||
$_html = str_replace('#lower#than#','<',$_html); | |||
$_html = str_replace('#greater#than#','>',$_html); | |||
//error_log(__METHOD__.__LINE__.' Charset:'.$displayCharset.' -> '.$_html); | |||
$_html = html_entity_decode($_html, ENT_COMPAT, $displayCharset); | |||
$_html = Api\Translation::convert($_html, $displayCharset, 'utf-8'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
html_entity_decode($_html, ENT_COMPAT, $displayCharset) converts htmlentities like eg. "ü" to a non-entity representation in $displayCharset in my example an "ü" in utf-8
Your code unconditional assumes $_html is utf-8 and needs to be decoded to $displayCharset (=utf-8), which means it does nothing
I assume the html_entity_decode is done to avoid double-encoding and it is removed now!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I changed this was that html_entity_decode can't handle some character sets, so for example `iso-8859-7:
2019/01/11 10:26:04 [error] 87934#100574: *24895 FastCGI sent in stderr: "PHP message: PHP Warning: html_entity_decode(): charset `iso-8859-7' not supported, assuming utf-8 in /usr/local/www/egwdocs/egroupware_work/html/egw/a
PHP message: #1 /usr/local/www/egwdocs/egroupware_work/html/egw/api/src/Mail/Html.php(405): html_entity_decode('\xB8\xE3\xE9\xED\xE5 \xE1\xED\xDC\xE3\xED\xF9\xF3\xE7 ...', 2, 'iso-8859-7')
PHP message: #2 /usr/local/www/egwdocs/egroupware_work/html/egw/api/src/Mail.php(1678): EGroupware\Api\Mail\Html::convertHTMLToText('\xB8\xE3\xE9\xED\xE5 \xE1\xED\xDC\xE3\xED\xF9\xF3\xE7 ...', 'iso-8859-7', 'utf-8')
PHP message: #3 /usr/local/www/egwdocs/egroupware_work/html/egw/mail/inc/class.mail_ui.inc.php(1693): EGroupware\Api\Mail->getHeaders('Public/secretar...', 1, 50, 'date', true, Array, NULL, true, true)
PHP message: #4 [internal function]: mail_ui::get_rows(Array, Array, NULL)
PHP message: #5 /usr/local/www/egwdocs/egroupware_work/html/egw/api/src/Etemplate/Widget/Nextmatch.php(601): call_user_func_array(Array, Array)
PHP message: #6 /usr/local/www/egwdocs/egroupware_work/html/egw/api/src/Etemplate/Widget/Nextmatch.php(363): EGroupware\Api\Etemplate\Widget\Nextmatch::call_get_rows(Array, Array, Array, NULL, Array, Object(EGroupware\Api\Ete
PHP message: #7 [internal function]: EGroupware\Api\Etemplate\Widget\Nextmatch::ajax_get_rows('mail_mtzo_88xW9...', Array, Array, 'nm', Array, 0)
PHP message: #8 /usr/local/www/egwdocs/egroupware_work/html/egw/api/src/Json/Request.php(179): call_user_func_array(Array, Array)
PHP message: #9 /usr/local/www/egwdocs/egroupware_work/html/egw/api/src/Json/Request.php(91): EGroupware\Api\Json\Request->handleRequest('EGroupware\Api\...', Array)
PHP message: #10 /usr/local/www/egwdocs/egroupware_work/html/egw/json.php(121): EGroupware\Api\Json\Request->parseRequest('EGroupware\Api\...', '{"request":{"pa...')
PHP message: #11 {main}
resulting in unreadable text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then the only full solution would be:
- Translation::convert() to utf-8
- html_entity_decode() with utf-8
Ralf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello Ralf,
I adjusted the code,
Do you think it's ok now?
I have it working in our installation for quite some time and had no problems.
Best regards,
Alexandros
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll build new 17.1 packages today, will merge it after, to have more time testing it, before it ends up in the packages.
Ralf
Mail, fix sneak preview encoding
No description provided.