Opened 18 years ago
Closed 18 years ago
#3238 closed defect (bug) (fixed)
Bug Fix in wpautop for Dangling Paragraph Tag in Wordpress Comments
Reported by: | Ghidra99 | Owned by: | |
---|---|---|---|
Milestone: | 2.1 | Priority: | normal |
Severity: | normal | Version: | 2.0.4 |
Component: | General | Keywords: | wpautop autop dangling paragraph format formatting comments comment has-patch needs-testing maint-candidate |
Focuses: | Cc: |
Description
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.
Attachments (2)
Change History (7)
#2
@
18 years ago
foolswisdom, I just took a look at the trunk code for formatting.php and it includes the bug as well.
It's at line 72:
$pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end
The updated code should read:
$pee = preg_replace('/\n?(.+?)(?:\n\s*|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end
Unfortunately, I'm not sure how to create patch files so this would be easily readable.
#3
@
18 years ago
- Keywords has-patch needs-testing added
Created and attached (untested) patches based on the given code for 2.0 branch and trunk.
Ghidra99, Can you add your fix as a patch? It is so much easier to read. Also, please consider commenting whether the same issue exists on trunk and a patch for it.