[wp-trac] [WordPress Trac] #7988: wpautop p (paragraph) bug with div

WordPress Trac wp-trac at lists.automattic.com
Tue Oct 28 13:25:18 GMT 2008


#7988: wpautop p (paragraph) bug with div
----------------------+-----------------------------------------------------
 Reporter:  filosofo  |       Owner:  anonymous                     
     Type:  defect    |      Status:  new                           
 Priority:  normal    |   Milestone:  2.7                           
Component:  General   |     Version:  2.7                           
 Severity:  normal    |    Keywords:  wpautop p formatting has-patch
----------------------+-----------------------------------------------------
 As [http://comox.textdrive.com/pipermail/wp-
 hackers/2008-October/022307.html Jan Erik Moström pointed out on wp-
 hackers], wpautop mis-parses the following line:

 {{{<div><a href="xx"> <img src="yy" /> </a> <p>text</p> </div>}}}

 The problem is this line in wpautop:

 {{{$pee = preg_replace('!<p>([^<]+)\s*?(</(?:div|address|form)[^>]*>)!',
 "<p>$1</p>$2", $pee);}}}

 This says that if a line has a {{{<p>}}} tag, some non-markup stuff,
 perhaps some space, followed by a closing tag of {{{</div>}}},
 {{{</address>}}}, or {{{</form>}}}, then the {{{<p>}}} is orphaned and
 should add a closing tag ({{{</p>}}}) on the right of the non-markup
 stuff.

 The mistake that it makes is allowing it to enclose empty space in
 {{{<p></p>}}}.  It makes this mistake by allowing space characters to be
 considered as the non-markup stuff.  My patch tells it not to do so by
 changing the above line to the following:

 {{{$pee = preg_replace('!<p>([^<\s]+)\s*?(</(?:div|address|form)[^>]*>)!',
 "<p>$1</p>$2", $pee);}}}

-- 
Ticket URL: <http://trac.wordpress.org/ticket/7988>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list