Skip to content

Mail, fix sneak preview encoding - #70

Merged
ralfbecker merged 4 commits into
EGroupware:masterfrom
asig2016:master_fix_sneak_preview_encoding
Apr 2, 2019
Merged

Mail, fix sneak preview encoding#70
ralfbecker merged 4 commits into
EGroupware:masterfrom
asig2016:master_fix_sneak_preview_encoding

Conversation

@asig2016

@asig2016 asig2016 commented Apr 1, 2019

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread api/src/Mail/Html.php
$_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');

@ralfbecker ralfbecker Apr 1, 2019

Copy link
Copy Markdown
Member

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!

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Member

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:

  1. Translation::convert() to utf-8
  2. html_entity_decode() with utf-8
    Ralf

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Member

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

@ralfbecker
ralfbecker merged commit 0336bc0 into EGroupware:master Apr 2, 2019
@ralfbecker

Copy link
Copy Markdown
Member

Thanks Alexandros :)

What is with that pull request from @filkaris
#41

ralfbecker added a commit that referenced this pull request Apr 2, 2019
@asig2016
asig2016 deleted the master_fix_sneak_preview_encoding branch April 3, 2019 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants