Make WordPress Core

Opened 13 years ago

Last modified 5 years ago

#15006 reopened defect (bug)

Closing tag for empty <p> tag is removed

Reported by: miqrogroove's profile miqrogroove Owned by:
Milestone: Priority: normal
Severity: minor Version: 3.0
Component: Formatting Keywords: wpautop needs-patch
Focuses: Cc:

Description (last modified by dd32)

I have a page post that starts like this:

<p style="text-align: right;">Text Here</p>
<p style="text-align: right;"></p>
More Text Here

The HTML source saves correctly, but the page output omits the closing tag for the second P element, causing the rest of the page to be invalid.

If you have any trouble reproducing this I will be happy to debug it on my server.

Attachments (2)

15006.diff (1.2 KB) - added by codeclarified 10 years ago.
Updates to wpautop() regex
15006-unit_test.patch (803 bytes) - added by jared_smith 9 years ago.
Unit test

Download all attachments as: .zip

Change History (19)

#1 @miqrogroove
13 years ago

The workaround I am currently using:

<p style="text-align: right;">Text Here</p>
<p style="text-align: right;">.</p>
More Text Here

Putting any text in the second paragraph somehow fixes the problem.

#2 @scribu
13 years ago

  • Component changed from General to Formatting

Confirmed.

#3 @scribu
13 years ago

  • Severity changed from normal to minor

Why do you need an empty <p> tag anyway?

#4 @demetris
13 years ago

Unsurprisingly perhaps, when I activated PHP Markdown (which automatically disables wpautop and does its own autoparagraphing) the problem disappeared.

#5 @miqrogroove
13 years ago

Why do you need an empty <p> tag anyway?

This ticket is about invalid output. If there's a problem in the html editor you should make a separate ticket for that.

#6 @dd32
13 years ago

  • Description modified (diff)

#7 @dd32
13 years ago

  • Keywords wpautop needs-patch added
  • Milestone changed from Awaiting Review to Future Release

#8 @iseulde
11 years ago

  • Keywords wpautop needs-patch removed
  • Resolution set to worksforme
  • Status changed from new to closed

Tested in 3.6.

#9 @iseulde
11 years ago

  • Keywords needs-patch wpautop added
  • Resolution worksforme deleted
  • Status changed from closed to reopened

Apologies, this is still a problem in 3.6.

Last edited 11 years ago by iseulde (previous) (diff)

#10 @miqrogroove
11 years ago

Indeed. Thank you for re-opening.

#11 @DrewAPicture
11 years ago

  • Milestone changed from Future Release to Awaiting Review

#12 @c3mdigital
11 years ago

In Trunk at r25093 The closing tag for the 2nd p element is not stripped.

<p style="text-align: right;">Text Here</p>
<p style="text-align: right;">
</p><p>More Text Here</p>

If I switch to visual editor the 2nd p element gets removed.

<p style="text-align: right;">Text Here</p>
<p>More Text Here</p>

#13 @nacin
10 years ago

  • Keywords needs-unit-tests added
  • Milestone changed from Awaiting Review to Future Release
  • Summary changed from Invalid Content Markup to Closing tag for empty <p> tag is removed

Let's get a unit test here. Is this still reproducible in trunk, given TinyMCE 4.0? Is this particular to wpautop(), to JS's wpautop, to TinyMCE, what?

#14 @codeclarified
10 years ago

  • Keywords has-patch added; needs-patch removed

Confirmed that this is still happening in trunk and is due to wpautop(). Used the following as a quick test:

<p style="text-align: right;">Some Text</p>
<p style="text-align: right;"></p>
<p>Moar text</p>
<p></p>
<p class="some-class">Some text <a href="#something">with an anchor</a> and some more text</p>
<p>No attr, but a nested <a href="#">here</a></p>
<p>Let's try an empty nested tag: <a href="#test"></a></p>

Attaching a patch that updates the regex near line 424 to handle <p> tags that have attributes such as the text-align mentioned above. This left some orphan </p> tags, and balanceTags() looks like it handled that issue, although this probably needs to be tested a bit more thoroughly. With the content above, the empty <p> tags are completely removed, other tags are left as expected.

That said, this may also be a wontfix issue - in HTML5 it is perfectly valid to have <p> tags without a matching closing tag.

Last edited 10 years ago by codeclarified (previous) (diff)

@codeclarified
10 years ago

Updates to wpautop() regex

@jared_smith
9 years ago

Unit test

#15 @jared_smith
9 years ago

I written a unit test in 15006-unit_test.patch which shows that 15006.diff causes more issues than it solves. That patch causes two additional unit tests to fail.

#17 @jared_smith
8 years ago

  • Keywords needs-patch added; needs-unit-tests has-patch removed
Note: See TracTickets for help on using tickets.