﻿id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc
7937,Problem with the wpautop function ads a extra <p> tag if there is more span tag,keithdsouza,anonymous,"There is a small bug in the cleanup code wpautop where it adds a extra <p> tag if there is a more section in the post.

The problem starts on this line of code

'''$pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', ""<p>$1</p>\n"", $pee); // make paragraphs, including one at the end'''

For starters run the method in a standalone mode on this html snippet

<p>hello</p> <span id=""more-2689""></span>  <p>hello1</p>

once this line of code is applied the new html code is

<p><p>hello</p></p> 
'''<p>''' <span id=""more-2689""></span>  
<p>hello1</p>'''</p>''' 

As you can see it added the <p> tag before span but missed out on adding the end tag, on the other hand it still added <p> tags to all other start and end tags

This line $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', ""$1"", $pee); 

removes the duplicate tags but the output leaves a invalid xhtml in the form of a open <p> tag

<p>hello</p> 
'''<p>''' <span id=""more-2689""></span> '''(missing close p tag here)'''
<p>hello1</p> 

The solution would be to change the first regex to this

$pee = preg_replace('/'''\n\n'''?(.+?)(?:\n\s*\n|\z)/s', ""<p>$1</p>\n"", $pee); // make paragraphs, including one at the end

Note the \n\n because you are already adding two line breaks in the earlier regex, hopefully you can add this to the coming version
",defect (bug),closed,normal,,Template,2.7,normal,invalid,wpautop,
