[wp-trac] [WordPress Trac] #3238: Bug Fix in wpautop for Dangling Paragraph Tag in Wordpress Comments

WordPress Trac wp-trac at lists.automattic.com
Fri Oct 13 18:36:55 GMT 2006


#3238: Bug Fix in wpautop for Dangling Paragraph Tag in Wordpress Comments
----------------------+-----------------------------------------------------
 Reporter:  Ghidra99  |       Owner:  anonymous                                                          
     Type:  defect    |      Status:  new                                                                
 Priority:  normal    |   Milestone:  2.0.5                                                              
Component:  General   |     Version:  2.0.4                                                              
 Severity:  normal    |    Keywords:  wpautop autop dangling paragraph format formatting comments comment
----------------------+-----------------------------------------------------
 I've figured out the wpautop bug that creates the hanging `</p>` tag in
 Wordpress comments.

 If you go to `functions-formatting.php` in Wordpress 2.0.4, located at
 "wp-includes/functions-formatting.php" you'll see that line 65 reads:
 {{{
 $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); //
 make paragraphs, including one at the end
 }}}
 This creates:
 {{{
 <p>Hello, my name is Hal.</p>
 <p>You've found my blog.
 </p>
 }}}
 The third `\n` (newline) is what is creating the problem. If you take it
 out, your final `</p>` tag will appear inline with your final sentence. It
 should read:
 {{{
 $pee = preg_replace('/\n?(.+?)(?:\n\s*|\z)/s', "<p>$1</p>\n", $pee); //
 make paragraphs, including one at the end
 }}}
 The text will now appear as:
 {{{
 <p>Hello, my name is Hal.</p>
 <p>You've found my blog.</p>
 }}}
 For added styling, you can aline the final `<p>` with the rest of your
 markup by adding three (or however many you need) tabs (`\t`) after the
 final newline (`\n`) in line 65. It should look like this:
 {{{
 $pee = preg_replace('/\n?(.+?)(?:\n\s*|\z)/s', "<p>$1</p>\n\t\t\t", $pee);
 // make paragraphs, including one at the end
 }}}

 IMO, the styling should be added so that the user receives well-formed
 HTML and XTHML in their source.

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


More information about the wp-trac mailing list