Opened 19 years ago
Closed 13 years ago
#1706 closed defect (bug) (fixed)
wpautop() not stripping <br /> tags before <p withattributes>
Reported by: | rockinfree | Owned by: | mdawaffe |
---|---|---|---|
Milestone: | 2.0.6 | Priority: | normal |
Severity: | normal | Version: | 2.3 |
Component: | Formatting | Keywords: | |
Focuses: | Cc: |
Description
<hr /><p>blah blah blah</p> <hr /><p class="center">blah blah blah</p>
Entered through the wp-admin/post.php page should become:
<hr /> <p>blah<br /> blah<br /> blah</p> <hr /> <p class="center">blah<br /> blah<br /> blah</p>
On the generated page (after being processed by wpautop()), but instead becomes:
<hr /> <p>blah<br /> blah<br /> blah</p> <hr /><br /> <p class="center">blah<br /> blah<br /> blah</p>
(note the extra <br /> after the second <hr /> tag)
The error is caused in functions-formatting.php wpautop():
$pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)!', '$1', $pee);
should be:
$pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee);
(Note that the original regexp is missing the [>]*, which is present for all other patterns in this function, and is necessary to allow, for example, <p class="center"> as in the repro case.)
Attachments (2)
Change History (18)
#1
@
19 years ago
- Keywords bg|has-patch bg|commit added
- Owner changed from anonymous to markjaquith
- Status changed from new to assigned
Thanks! Patch added.
Excellent bug report, by the way. Much appreciated.
#6
@
17 years ago
- Milestone set to 2.4 (next)
- Resolution fixed deleted
- Status changed from closed to reopened
- Version changed from 1.5.2 to 2.3
This actually created awkward behavior, which I have encountered working with numerous customers.
Most HTML includes line breaks through out it to easy readability. If within paragraph tags, the best assumption is that new lines <br />s will be explictly defined.
#11
@
15 years ago
Please close as wontfix. Fixing things will break other things and vice-
versa. I do not know a single serious developer that wants to touch this.
Best would be to get a binding description first what must (not)/should (not)/can
(not) be done by wpautop. Then testcases must be written (executeable ones) and then the function can be developed accordingly.
related: #2833
#12
follow-up:
↓ 14
@
15 years ago
- Keywords needs-unit-tests added; br wpautop functions-formatting.php needs-patch removed
- Milestone changed from 2.9 to Future Release
Agreed we need comprehensive autop test cases before touching the code in this way.
Moving to Future.
#14
in reply to:
↑ 12
@
15 years ago
Replying to westi:
Agreed we need comprehensive autop test cases before touching the code in this way.
Moving to Future.
Does this mean you agree with "not a single serious developer wants to touch this" as well?
#16
@
13 years ago
- Keywords needs-unit-tests removed
- Milestone changed from Future Release to 2.0.6
- Resolution set to fixed
- Status changed from new to closed
Most HTML includes line breaks through out it to easy readability. If within paragraph tags, the best assumption is that new lines <br />s will be explictly defined.
This is not related to the initial bug report, nor is it something that we would ever address at this point, as automatic line breaks are integral to wpautop.
Considering this fixed on 2.0.
Fixed version of file with line 75 in wpautop() updated (sorry, no diff on this system)