Make WordPress Core

Opened 4 years ago

Last modified 3 years ago

#48256 new defect (bug)

WP remove first <p> in <td>

Reported by: sebafaim's profile Sebafaim Owned by:
Milestone: Future Release Priority: normal
Severity: major Version: 5.2.3
Component: Editor Keywords: needs-patch needs-unit-tests
Focuses: Cc:


When I create table and add text inside it remove first <p> but let </p>
Example : <td><span class="" ></span></p>

Attachments (3)

TinyMCE Advanced editor.png (155.8 KB) - added by samful 4 years ago.
source-code.png (30.0 KB) - added by samful 4 years ago.
front-end.png (83.4 KB) - added by samful 4 years ago.

Download all attachments as: .zip

Change History (9)

#1 follow-up: @mohsinrasool
4 years ago

@Sebafaim Please explain how can I reproduce it.

#2 in reply to: ↑ 1 @Sebafaim
4 years ago

Replying to mohsinrasool:

@Sebafaim Please explain how can I reproduce it.

I create a table with TinyMCE Advanced, and I add text inside the cell, and after I save.
I'm not doing anything else. Maybe wpautop ?

#3 @SergeyBiryukov
4 years ago

  • Component changed from General to Editor
  • Focuses coding-standards removed

#4 @alpipego
4 years ago

  • Keywords needs-patch added
  • Severity changed from minor to major

In wpautop a block element immediately followed by an inline(-block) element causes this issue. For me it was <div><img …>…</div> getting turned into <div><img …></p>…</div>.

The issue is that markup like this:

    <img src="" alt="" width="800" height="600" />
    <p>Here is some paragraph</p>

gets split into

<div><img src="" alt="" width="800" height="600" />
<p>Here is some paragraph</p>

concatenated to

<p><div><img src="" alt="" width="800" height="600" /></p>
<p><p>Here is some paragraph</p></p>

The opening <p> then gets removed for the first fragment above in but the closing one stays.

I've changed the severity to major, since this leads to invalid HTML markup in the output.

#5 @samful
4 years ago

  • Keywords 2nd-opinion added

This ticket was never really very well explained, so I will try and explain my understanding of it:

The Issue:

Using the "TinyMCE Advanced" plugin and gutenburg causes some custom html to be deleted.

Examples Given:

<td><span class="" ></span></p>

removes the <p> element

    <img src="" alt="" width="800" height="600" />
    <p>Here is some paragraph</p>

Adds some <p> elements and then the opening <p> gets deleted

My Observation:

I experienced no issues at all and submitted screen-shots of my example. Also, yes there is a line in wpautop which deletes the opening <p> ,but also there is a line that deletes the closing <p> right next to it:

If someone else can replicate the original issue with proof or confirm what I found, then please reply with screen-shots or close the ticket.

p.s. there is also a setting in that plugin to "Keep paragraph tags in the Classic block and the Classic Editor"

"Stop removing <p> and <br> tags in the Classic Editor and show them in the Text tab. This will make it possible to use more advanced coding in the Text tab without the back-end filtering affecting it much. However it may behave unexpectedly in rare cases, so test it thoroughly before enabling it permanently. Line breaks in the Text tab in the Classic Editor would still affect the output, in particular do not use empty lines, line breaks inside HTML tags or multiple <br> tags."

4 years ago

4 years ago

#6 @noisysocks
3 years ago

  • Keywords needs-unit-tests added; 2nd-opinion removed
  • Milestone changed from Awaiting Review to Future Release

I was able to confirm this by pasting this into the Code Editor and previewing the page.

    <img src="" alt="" width="800" height="600" />
    <p>Here is some paragraph</p>

There is an extraneous </p> which is invalid HTML.

Looks like a bug with wpautop. We should add tests that cover the edge case. Invalid HTML should never be produced.

Note: See TracTickets for help on using tickets.