- Issue created by @jan kellermann
- Merge request !14Converting html before creating DOM Document. β (Merged) created by jan kellermann
- π©πͺGermany jurgenhaas Gottmadingen
I've looked into this and I'm not sure if it's sufficiently dealing with all possible issues around encoding. As we spent quite some time on a similar issue in the past, let me post the way we've used to resolve this:
$content = mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'); $document = \Drupal\Component\Utility\Html::load($content); // Do all the manipulation here. $html = HTML::serialize($document); $html = str_replace(' ', "\r", $html); $html = mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8');
In the end, we seem to have covered everything related to non-ascii stuff. Leaveing the issue at NR as it's up to you whether you want to make use of this.
- π©πͺGermany sascha_meissner Planet earth
Had a hard time reproducing the issue and finally found out that it only happens when having twig.config.debug=true and it happens since Drupal added utf-8 icons to the twig debug comments, which must have been a recent update.
both, janΒ΄s and jurgenΒ΄s code fix the display of the specialchars in the browser, but also both fail to encode the icons in the twig-debug-comments back correctly :(
- π©πͺGermany jan kellermann
According to #3488214 i set state to RTBC.
- π©πͺGermany jan kellermann
@sascha_meissner: The encoding back was missing at all :) I added this in last commit:
diff --git a/src/Utility/KlaroHelper.php b/src/Utility/KlaroHelper.php index 7c54f58..336d418 100644 --- a/src/Utility/KlaroHelper.php +++ b/src/Utility/KlaroHelper.php @@ -805,6 +805,7 @@ class KlaroHelper { if ($complete_html) { $html = $dom->saveHTML(); + $html = mb_decode_numericentity($html, [0x80, 0x10FFFF, 0, 0x1FFFFF], 'UTF-8'); } else { $html = Html::serialize($dom);
- π©πͺGermany jan kellermann
Merged to dev. Thank you all for feedback and testing.
-
jan kellermann β
committed 287e91cf on 3.x
Update changelog.md Added #3483397 and #3488214
-
jan kellermann β
committed 287e91cf on 3.x
Automatically closed - issue fixed for 2 weeks with no activity.