-
Notifications
You must be signed in to change notification settings - Fork 823
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
HTMLEditorField is not able to show html/xml code examples #11207
Comments
Our primary issue stems from the double encoding of special characters. Initially, we encode them in HTMLEditorField::ValueEntities(), encompassing all content within the WYSIWYG text area. Subsequently, on the client side within Given that this encoding is necessary when a user initially adds an image, we need to address cases where users simply save or reload existing content containing the image short code. To address this, we should implement a "double_encode" in public function ValueEntities(){
-return htmlentities($this->Value() ?? '', ENT_COMPAT, 'UTF-8', false);
+return htmlentities($this->Value() ?? '', ENT_COMPAT, 'UTF-8', true);
}
Alternatively, developing a custom plugin for example code insertion is an option, though it may be labor-intensive and likely won't garner significant demand. To rectify situation with special characters in image short code, it's advisable to make modifications to |
That's a great investigation! It does look like "double encoding" is the correct behaviour in this context. You don't want HTMLEditor to second guess the data it is getting. Patching I did notice that the Insert Embed modal had the same problem InsertMediaModal had with All things considered, I would like content authors to be able to put whatever text they want in any context. But if I have to choose, I would rather them being able to correctly write mark up text in the WYSIWYG rather than being able to put |
Module version(s) affected
5.1.23
Description
This commit: 037168a turned off double encoding of html entities in HTMlEditorField value in an attempt to fix an issue with html entities in shortcodes. That introduced a major bug which prevents TinyMCE to show xml/html code examples.
How to reproduce
Use <strong>tag</strong> to make it bold.
<p>Use <strong>tag</strong> to make it bold.</p>
is stored in DB. This is correct value.The reason is that HTMLEditorField doesn't double encode html entities (4th parameter of htmlentities function is set to false) and produces this textarea value:
instead of this:
Acceptance criteria
Related
PR
The text was updated successfully, but these errors were encountered: