You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
automatic conversion of html entities after reloading the page in the editor #15792
[Feature] Rich TextRelated to the Rich Text component that allows developers to render a contenteditable[Package] Rich text/packages/rich-text[Type] BugAn existing feature does not function as intended
The used html entities (curly braces) are automatically converted to "normal" characters after reloading the page in the editor.
Tested in code and paragraph block.
pasting {text{ in visual or text mode replaces HTML entities on blur or on save + reload, but not on save alone, causing bad UX
pasting an incorrect {text{ (no semicolon at the end) replaces the 1st HTML entity and when correcting the second one it doesn't get replaced.
We need to see if it is possible to not replace HTML entities at all or at least if we do to do it consistently.
Note: the classic editor is even more unpredictable, pasting {text} results in {}, the word text is gone and it converts the entities even though they are malformed (missing semicolon).
The semicolon was only forgotten when creating this post, but not in the code of the editor! (I should have formatted it as code here, otherwise the curly braces will be converted here as well)
Yes, the conversion happens by the way when switching from the text to the visual view.
It would be nice if there would be a way to disable the automatic conversion completely.
Later you could restrict this to certain entities.
The main reason here is that when parsing a block that relies on html sourced attributes, hpq (our parser library) uses element.innerHTML to extract the HTML from the block attribute (inserting the HTML into a random element and extracting the bits we need), browsers though automatically convert HTML entities in their DOM APIs.
So a potential solution would be to avoid using the browser APIs to parse the block attributes, but I don't know exactly if there's an alternative there that doesn't involve writing a custom HTML parser (which sounds too heavy for the issue at hand both in terms of maintainability and performance).
I wanted to make clear in this issue that this prevents non-BMP unicode characters, such as “🛈” and most emoji, from being able to be used at all on some installations. Non-BMP characters can't be used when the underlying MySQL database uses utf8mb3 encoding. If you try to save a draft with non-BMP character, it will show the error "Updating failed. Could not update post in the database."
Editing as HTML and using an entity would be a workaround, but this automatic conversion of entities to their characters prevents this workaround.
In my case, I'm on a hosted solution where I'm not sure that I can change the database/table/column character sets. Even if I could, I still think this behavior in WP should be addressed.
[Feature] Rich TextRelated to the Rich Text component that allows developers to render a contenteditable[Package] Rich text/packages/rich-text[Type] BugAn existing feature does not function as intended
Activity
draganescu commentedon Jun 13, 2019
Hi @GitHub-Mike,
This looks like an inconsistent behaviour:
{text{in visual or text mode replaces HTML entities on blur or on save + reload, but not on save alone, causing bad UX{text{(no semicolon at the end) replaces the 1st HTML entity and when correcting the second one it doesn't get replaced.We need to see if it is possible to not replace HTML entities at all or at least if we do to do it consistently.
Note: the classic editor is even more unpredictable, pasting
{text}results in{}, the word text is gone and it converts the entities even though they are malformed (missing semicolon).GitHub-Mike commentedon Jun 13, 2019
Hi @draganescu,
The semicolon was only forgotten when creating this post, but not in the code of the editor! (I should have formatted it as code here, otherwise the curly braces will be converted here as well)
Yes, the conversion happens by the way when switching from the text to the visual view.
It would be nice if there would be a way to disable the automatic conversion completely.
Later you could restrict this to certain entities.
youknowriad commentedon Jun 1, 2023
The main reason here is that when parsing a block that relies on
htmlsourced attributes,hpq(our parser library) useselement.innerHTMLto extract the HTML from the block attribute (inserting the HTML into a random element and extracting the bits we need), browsers though automatically convert HTML entities in their DOM APIs.So a potential solution would be to avoid using the browser APIs to parse the block attributes, but I don't know exactly if there's an alternative there that doesn't involve writing a custom HTML parser (which sounds too heavy for the issue at hand both in terms of maintainability and performance).
lathanh commentedon Sep 10, 2026
I wanted to make clear in this issue that this prevents non-BMP unicode characters, such as “🛈” and most emoji, from being able to be used at all on some installations. Non-BMP characters can't be used when the underlying MySQL database uses utf8mb3 encoding. If you try to save a draft with non-BMP character, it will show the error "Updating failed. Could not update post in the database."
Editing as HTML and using an entity would be a workaround, but this automatic conversion of entities to their characters prevents this workaround.
In my case, I'm on a hosted solution where I'm not sure that I can change the database/table/column character sets. Even if I could, I still think this behavior in WP should be addressed.