﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc
3238	Bug Fix in wpautop for Dangling Paragraph Tag in Wordpress Comments	Ghidra99	anonymous	"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."	defect (bug)	closed	normal	2.1	General	2.0.4	normal	fixed	wpautop autop dangling paragraph format formatting comments comment has-patch needs-testing maint-candidate	spencerp
