WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#3669 closed defect (bug) (fixed)

Missing close </p> tag in wpautop

Reported by: scenic Owned by:
Milestone: 2.2 Priority: high
Severity: normal Version: 2.1
Component: Template Keywords: wpautop xhtml has-patch
Focuses: Cc:

Description

wpautop seems to change <p><div></div></p> to <div><p></div>
(note the lack of a closing </p> in the second). This broke XHTML
compliance in some text appended by a custom plugin of mine, but I'm
guessing it would affect any div's I put in via the edit page.

I've attached the patch, but the short version of the fix is adding
this line below after line 66 in wp-includes/formatting.php.

$pee = preg_replace( '|(</div[>]*>\s*)</p>|', "</p>$1", $pee );

Attachments (1)

ptag-formatting.patch (820 bytes) - added by scenic 7 years ago.
Patch to fix this bug

Download all attachments as: .zip

Change History (10)

scenic7 years ago

Patch to fix this bug

comment:1 scenic7 years ago

  • Version set to 2.1

comment:2 charleshooper7 years ago

  • Keywords has-patch added

comment:3 stephenju7 years ago

The problem was introduced in this [4565] which was intended to fix #2647. But the patch in #2647 doesn't contain lines 66 to 68 in [4565]. Where were those lines from?

comment:4 stephenju7 years ago

  • Priority changed from low to high

This is cause plugins that generate <div> tags to fail. WPG2 is the prime example.

Could someone please explain what the extra lines (66-68) in [4565] do? I suggest backing that 3 lines out to fix this problem.

comment:6 ryan7 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [4894]) Don't insert p inside of div. fixes #3669

comment:7 JeremyVisser7 years ago

  • Milestone changed from 2.1.1 to 2.2
  • Resolution fixed deleted
  • Status changed from closed to reopened

I can still reproduce this bug. Running WordPress MU 1.2.1 (the wpautop() function is currently exactly the same as in trunk with your fix).

comment:8 rob1n7 years ago

Nope. Fixed. Works on r5269.

comment:9 rob1n7 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.