-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Unescaped HTML inside shortcode attributes breaks block validation #13399
Comments
I can't reproduce this. Is there a specific series of steps we could have to better test? |
The error occurs when trying to activate the plugin xili Post in Post. The original shortcode looks like this:
When the classic editor is in visual mode when opening the post, the shortcode is rewritten to:
When opening the post using Gutenberg, it is automatically put in a Classic Editor block and the code is replaced with:
When using Gutenberg from scratch and using the Shortcode block, I get the following warning upon reopening the post:
(Original warning in Dutch, the exact text may differ) Converting it to HTML by clicking on the button, it produces:
Using an HTML block produces the same result.
My best option is to use the classic editor in code mode. But whenever I save any post in visual mode and then open this post (and it's a post that is supposed to be updated regularly, so that happens quite often) it trashes the code again and I have to rebuild it. |
Thanks for the report, @chunkyRice. From your account and what I then reproduced, this seems unrelated to quotes, but related to how escaped and unescaped HTML entities are handled. This also affects the classic editor. For instance: This is because any rich-text editor (including classic) will be looking for HTML elements in post content. Inside the shortcode there is such an element (
Incidentally, the above snippet is exactly what we obtain if we paste the shortcode when in Visual mode instead of Text mode: When this is the case, Gutenberg has no problem parsing the content and helping with the conversion: Note: I understand that the shortcode in question, There may be room for improvement somewhere in Gutenberg to make situations like these easier on users, but I'm not sure which. |
@mcsf How does this relate to the RichTex component? |
@iseulde: Not very specifically, this is more about the serialisation layer. Fine to remove whatever labels you like. @chunkyRice, does the explanation in this issue help you in any way? Is there a course of action you see for yourself or for core Gutenberg? Otherwise, I'm inclined to say there are no action items for Gutenberg and that we can close this issue. Let me know! Thanks. |
I've tested what @mcsf suggested, but it only works a single time. When you save the page and reopen it, everything is a mess again. I expected the snippet block to handle raw ascii text, but apparently that's not the case. Doing so would solve this problem, but from your answers I understand that it would also be a potential safety hazard. I've submitted the problem to the support forum of the plugin. |
Yeah, never mind what I said. The block-validation process runs the serialised HTML through the block parser, where attributes are parsed according to their type: gutenberg/packages/blocks/src/api/parser.js Lines 181 to 217 in f2c5db6
The block type for Shortcode defines that the The discrepancy between the serialised escaped HTML ( Changing Shortcode's |
To me, particularly because it saves using It's worth pointing out that regardless of whether the source is changed, the default WordPress |
Thanks for the input. Opened #13609. |
Note, this is a direct port of a ticket filed on Trac and which can be found here: https://core.trac.wordpress.org/ticket/45684
(edited by mcsf to use the term "quotes" throughout)
The text was updated successfully, but these errors were encountered: