gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Entering ">" into the RichText component causes block validation failure

Open vrk opened this issue 7 years ago • 0 comments

You can repro this easily via my remix of the Gutenberg Block Kit Glitch project: https://repro-richtext-bug.glitch.me/

Steps to repro:

  1. Go to https://repro-richtext-bug.glitch.me/
  2. Type > into the RichText component -- see that it renders as > (which might be a separate bug)
  3. Refresh the page

Expected behavior:

Should either render as literally >, or it should consistently evaluate the HTML entity and render>.

Actual behavior:

The block gets into a bad state after refreshing: "This block contains unexpected or invalid content"

Error in the console:

Block validation: Block validation failed for `gutenberg-block-kit/remix` (Object).

Content generated by `save` function:

<p class="wp-block-gutenberg-block-kit-remix">&gt;</p>

Content retrieved from post body:

<p class="wp-block-gutenberg-block-kit-remix">&amp;gt;</p>
(anonymous) @ validation.js:265

(I verified this also repros when installed in WordPress as well.)

Thanks for taking a look and let me know if there's any way I can help! Gutenberg and the Block Kit on Glitch have been very cool to play with!


Context: Why am I trying to write &amp;gt;, anyway?

I found this bug because I'm writing a rich text code block plugin that lets you write code snippets and also add basic styling to them (so that you can bold part of a code snippet).

My plugin basically works, but RichText renders HTML entities like ">" even when you set the attribute content to the escaped value (which I think is #15636).

I can imagine wanting to write &gt; in a code snippet, so until #15636 is fixed, my workaround was going to be to write &amp;gt;, which is what led me to this bug!

vrk avatar Jun 24 '19 05:06 vrk