WordPress.org

Make WordPress Core

Opened 4 weeks ago

Last modified 4 weeks ago

#45684 new defect (bug)

Gutenberg breaks shortcode with nested quotes

Reported by: siggeste Owned by:
Milestone: Awaiting Review Priority: normal
Severity: critical Version: 5.0.1
Component: Editor Keywords: needs-patch ux-feedback
Focuses: Cc:

Description

When inserting shortcode containing both single and double parentheses (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 parentheses will be converted to double parentheses, 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 parentheses is replaced by a single line-break. Ouch.

Change History (4)

#1 @joyously
4 weeks ago

Just to be clear: You are calling ' a single parentheses and " a double parentheses?

I call these parentheses () and this is single quote ' and double quote ".

And are you aware there is a HTML view in the block editor?

#2 @SergeyBiryukov
4 weeks ago

  • Component changed from Shortcodes to Editor

#3 @siggeste
4 weeks ago

  • Summary changed from Gutenberg breaks shortcode with nested parentheses to Gutenberg breaks shortcode with nested quotes

Yes, you're right. They're quotes, not parentheses. That's what you get for filing bug reports when you can hardly keep your eyes open. I've changed the title/summary of the ticket but I can't seem to edit my description. If you prefer, I can make a new ticket with a proper description.

And when you say there's "a HTML view in the block editor", do you mean the block called Custom HTML? Because that one replaces all the single quotes with double ones. What works in the classic editor is not so much the insertion of raw html, but switching to text view (using the button in the top right of the editor) exposing the underlying html. I can't find such a toggle button in Gutenberg and since it relies on precise formatting I assume it will never be added either.

#4 @siggeste
4 weeks ago

I've found the option to view the text as raw html called Code Editor, tucked away in the hamburger menu at the top right. Unfortunately it behaves similar to an HTML Block. Whenever I save the page, all nested single quotes are changed into double ones.

I also discovered a new quirk. I thought that a page remembered which editor and state were used last. The editor is indeed remembered (a flag is set) but the state can sometimes inadvertently switch back to the Visual Editor, breaking the code.

Note: See TracTickets for help on using tickets.