#2813 closed defect (bug) (wontfix)
wpautop() adding erroneous <br/> tags
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.0.3 |
Component: | Template | Keywords: | <br> has-patch needs-testing |
Focuses: | Cc: |
Description
A few things happens when posting a well formed valid xhtml content via xml-rpc.
- <br/> tags are converted to <br>
- When publishing WP appends extra <br/> (actually <br>) tags even if the post is a well formed validated xhtml content.
To reproduce, compose a simple entry with a <br/> using a client editor (in our case, we used our application - Zoundry). The xhtml content looks like:
<p>Hello <br /> Worlds</p>
Debug logs shows that the xml-rpc description field is as expected:
<p>Hello <br/> Worlds</p>
Next, go into the WP MySQL database and look at the posted content:
In, WP 2.0, noticed that the <br/> is converted to <br>. E.g.:
<p>Hello <br> Worlds</p>
I found that this is due to a bug in kses.php. It seems this part (<br/> converted to <br>) is resolved in WP 2.0.1. That is, the database content is:
<p>Hello <br/> World</p>
When the above content is published via WP, the html in the published entry inserts two extra <br> tags and also note that the <br/> is converted to a non-valid <br> tag (possibly a bug in wpautop):
<p>Hello<br> <br><br> World</p>
This applies to WP 2.0 and 2.01 (verified) and users have reported same issue in WP 2.02.
Attachments (1)
Change History (16)
#2
@
17 years ago
Another update - it seems, in 2.03, the <br/> tags are well-formed, though the extra <br/> tags are still inserted.
#3
@
17 years ago
- Milestone changed from 2.0.3 to 2.1
- Summary changed from <br /> tags are not handled correctly when posted via xml-rpc to Extra <br /> tags added when posted via xml-rpc
- Version changed from 2.0.2 to 2.0.3
#6
@
16 years ago
I've confirmed that the double <br /> problem still exists in -trunk, but it doesn't have anything to do with XML-RPC. If you turn off the visual editor and paste the example into a blog post:
<p>Hello <br /> Worlds</p>
You get the same double <br />.
#8
@
16 years ago
Please, if you're going to change this behavior, give us a way to know whether the line break conversion will be applied or not! We put a lot of work into Windows Live Writer to work correctly with WP's current behavior, for both posting and fetching existing posts.
As an example of what not to do, Movable Type has a per-post setting for whether line breaks should be converted to p and br tags, but there's no way for an XML-RPC client to reliably know what the setting is for an existing post.
#9
@
16 years ago
- Component changed from XML-RPC to General
- Keywords xml-rpc removed
- Owner changed from anonymous to pishmishy
- Status changed from new to assigned
- Summary changed from Extra <br /> tags added when posted via xml-rpc to wpautop() adding eroniuous <br/> tags
Problem is located in lines 81-85 of formatting.php (at least it disappears when you comment these lines out)
if ($br) { $pee = preg_replace('/<(script|style).*?<\/\\1>/se', 'str_replace("\n", "<WPPreserveNewline />", "\\0")', $pee); $pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); // optionally make line breaks $pee = str_replace('<WPPreserveNewline />', "\n", $pee); }
#10
@
16 years ago
- Summary changed from wpautop() adding eroniuous <br/> tags to wpautop() adding erroneous <br/> tags
#11
@
16 years ago
- Keywords has-patch needs-testing added
My regex-foo isn't strong but I think that the problem was a * where a + was intended. Pretty sure the bug is somewhere in that regular expression although I'm not entirely sure if I've fixed it or just broken the intended functionality =)
Update - another user reported the same issue (extra <br/> tags) in v 2.0.3.