Skip to content

Unescaped HTML inside shortcode attributes breaks block validation #13399

@karmatosed

Description

@karmatosed

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)

When inserting shortcode containing both single and double quotes (like so: [plugin query="a='b' c=1"] ) using a Shortcode Block, Gutenberg will show a warning next time you load the page, saying that the Block contains unexpected or incorrect code. You can choose to "restore" the code by converting it to a Block (whatever that means in this context), completely wrecking your code, or you can convert it to Custom HTML in which case the single quotes will be converted to double quotes, breaking the HTML. This also happens when you insert the code into the page using Custom HTML right away. Either way, the shortdcode will not work properly and there's no way around it, using vanilla WP 5.0.

The only solution I have found, is to install the Classic Editor Plug-In and then switch to Text View. That basically rules out the possibility of any of my editors being able to make and maintain pages containing such shortcodes, which is extremely not cool. (I'm classifying this as a Bug of Critical Severity, since it effectively breaks an essential plug-in of my site.)

When saving the above code as a Reusable Block (I'm using WP with a Dutch translation so the exact term may differ), you get to see the resulting HTML. Everything between the single quotes is replaced by a single line-break. Ouch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] Paste[Type] Plugin InteroperabilityIncompatibilities between a specific plugin and the block editor. Close with workaround notes.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions