WordPress.org

Make WordPress Core

Opened 19 months ago

Last modified 19 months ago

#38656 new defect (bug)

wpautop incorrectly handling paragraphs within block elements

Reported by: pento Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Formatting Keywords: has-patch needs-unit-tests needs-testing
Focuses: Cc:

Description

When there are two line breaks within a block element, wpautop() will replace it with </p><p>, but the corresponding opening and closing tags won't exist.

For example, <div>a\n\nb</div> will produce <div>a</p><p>b</div>, when it really should produce <div>\n<p>a</p>\n<p>b</p>\n</div>.

Attachments (3)

38656.diff (3.8 KB) - added by pento 19 months ago.
38656.2.diff (5.6 KB) - added by pento 19 months ago.
38656.3.diff (6.8 KB) - added by pento 19 months ago.

Download all attachments as: .zip

Change History (6)

@pento
19 months ago

#1 @pento
19 months ago

38656.diff is a first pass at fixing this, it needs many more unit tests.

@pento
19 months ago

#2 @pento
19 months ago

38656.2.diff makes this all work with nested peeable and unpeeable elements, and adds more unit tests.

@pento
19 months ago

#3 @pento
19 months ago

38656.3.diff adds code comments, and some more complex tests.

There's probably value in adding some intelligence to the closing HTML tag detection, so we can handle some basic invalid HTML. For example, a browser will automatically correct <div><span>foo</div>, and treat it as <div><span>foo</span></div>, but wpautop() will get $peeable out of sync, causing problems.

Note: See TracTickets for help on using tickets.