[wp-trac] [WordPress Trac] #27350: Invalid HTML Output

WordPress Trac noreply at wordpress.org
Wed Aug 6 19:58:38 UTC 2014


#27350: Invalid HTML Output
--------------------------------------+------------------------------
 Reporter:  miqrogroove               |       Owner:
     Type:  defect (bug)              |      Status:  new
 Priority:  normal                    |   Milestone:  Awaiting Review
Component:  Formatting                |     Version:  3.8
 Severity:  normal                    |  Resolution:
 Keywords:  wpautop needs-unit-tests  |     Focuses:
--------------------------------------+------------------------------

Comment (by jond):

 I took a deeper look and found that my assumptions for the unit tests were
 faulty. I updated the test for #27350 along with the tests I added for
 #18136 and #20444. For clarity `Autop-27350-fixed.diff` includes the
 updated unit tests for all three tickets (#27350, #18136, and #20444).

 I submitted the fix (`formatting-27350.diff``) I developed for this ticket
 (#27350) which also fixes #18136 and #20444. In addition to passing the
 new unit tests, it passes all existing unit tests.

 I found that the `$allblocks` preg fragment allowed `tr` in it to match
 `<track>` elements and the `p` in the preg fragment matched `<param>`
 elements. Appending `\b` outside of the subpattern matches the word
 boundary to prevent unintented elements from matching the pattern.

 Adding the `ltrim` to the `preg_split` prevents an empty element in the
 `$pees` blocks which can cause some other odd cases (empty `<p></p>`
 blocks).

 The primary fix to the unit tests adds `preg_match` inside the `$pees`
 loop. It avoids unnecessarily wrapping block elements in `<p>` tags and
 handles the special case of `<blockquote>` tags.

 I imagine this will cause a performance penalty. I have not yet run
 benchmarks to understand if a signficant hit is going to occur. I will
 report back on this.

 Understanding that all of this will work will be supplanted by #25856, it
 is still advantageous to clean up these edge cases now and add coverage to
 the unit tests.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/27350#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list