WordPress.org

Make WordPress Core

Opened 6 months ago

Last modified 3 months ago

#46861 accepted defect (bug)

Block Editor: Classic block missing content in Preview

Reported by: joyously Owned by: SergeyBiryukov
Milestone: 5.3 Priority: normal
Severity: normal Version: 5.1
Component: Editor Keywords:
Focuses: Cc:

Description (last modified by SergeyBiryukov)

Tracking https://github.com/WordPress/gutenberg/issues/14861 here since it appears that the problem could be in content filters.

The content is visible in the editor, but the Preview is missing some content.

To reproduce

  1. I was using the Theme Unit Test data from https://github.com/WPTRT/theme-unit-test/
  2. Click to edit the Post titled "Markup: HTML Tags and Formatting"
  3. Scroll down to see that the Table follows the Block Quote.
  4. Click on Preview.
  5. See that there is no Table heading following the Block Quote and the formatting of the rest of the page is for blockquote.

Expected behavior
The preview should match the content in the editor.

This is how it looks in the editor:

And this is how the preview looks:

Attachments (2)

1.jpg (119.2 KB) - added by SergeyBiryukov 3 months ago.
2.jpg (145.8 KB) - added by SergeyBiryukov 3 months ago.

Download all attachments as: .zip

Change History (10)

This ticket was mentioned in Slack in #forums by joyously. View the logs.


5 months ago

This ticket was mentioned in Slack in #core by joyously. View the logs.


5 months ago

#3 @SergeyBiryukov
5 months ago

  • Milestone changed from Awaiting Review to 5.3

This ticket was mentioned in Slack in #core by joyously. View the logs.


3 months ago

#5 @SergeyBiryukov
3 months ago

  • Owner set to SergeyBiryukov
  • Status changed from new to accepted

#6 @SergeyBiryukov
3 months ago

This might be related to https://github.com/WordPress/gutenberg/issues/13655.

Could you check the value of mbstring.func_overload PHP setting on your install? phpinfo() should display it.

@SergeyBiryukov
3 months ago

@SergeyBiryukov
3 months ago

#7 @SergeyBiryukov
3 months ago

  • Description modified (diff)

#8 @SergeyBiryukov
3 months ago

I was able to reproduce the issue with the following example:

<a href="#" title="&lt;cite&gt; represents a reference to a creative work.">...</a>

It results in this output on the front end:

<a href="#" title="<cite> represents a reference to a creative work.&#8221;>&#8230;</a>

Note the closing quote converted to &#8221;, breaking any markup that follows.

With the wptexturize() filter disabled, the input works as expected.

Using the Classic Editor (in both Visual and Text mode), the output is correct even with wptexturize() enabled:

<a title="&lt;cite&gt; represents a reference to a creative work." href="#">&#8230;</a>

So this appears to be a wptexturize() issue that only manifests with the Block Editor. I think the difference is that the Block Editor does not preserve the escaped &lt;cite&gt; tag in the title attribute, converting it to <cite>, and wptexturize() is confused by that.

I guess the Block Editor should preserve &lt; and &gt; entities in HTML attributes. I've reopened the original GitHub issue and commented there.

Note: See TracTickets for help on using tickets.