This is when used with a format filter that implements 'Line break converter"
_filter_autop('') == "br" tag.
the doc for the function says :
"Convert line breaks into [p] and [br] in an intelligent fashion.
* Based on: http://photomatt.net/scripts/autop"
The above link reads
"Basically it takes PHP’s nl2br function to the logical next step and converts double line breaks to paragraphs where applicable, does line breaks as before, and best of all it’s aware of block-level HTML tags so it won’t mess up your page"
Yet we have nl2br('') == ''.
So I'm not sure 1) if it's a bug or a feature 2) where it should be corrected if necessary.
I noticed this on an extraneous br tag being output when a rendering a node with no body.
Comment | File | Size | Author |
---|---|---|---|
#12 | filter_14.patch | 1.21 KB | RobRoy |
#5 | filter.module_26.patch | 1.19 KB | yched |
Comments
Comment #1
yched CreditAttribution: yched commentedComment #2
webchickI've noticed this too, and would consider it a bug. At one point I'd filed an issue about this but I can't seem to find it now, and in any case this is a better description than mine. ;) I believe I'd traced it to the filter_xss stuff, which got into Scary Regex Hell (tm) which was beyond my level of debugging skills.
Comment #3
Steven CreditAttribution: Steven commentedCorrecting title. Check_plain() will never add HTML to the output.
Comment #4
yched CreditAttribution: yched commentedEr, right, stupid mistake - sorry.
Comment #5
yched CreditAttribution: yched commentedI think I nailed this to the following lines in _filter_autop :
1st line creates some
<p>...</p>\n
blocks.2nd line corrects some seemingly "strange" effects in this first line where empty
<p></p>
are created and removes them _but_ forgets the trailing\n
in the capturing pattern.Attached patch corrects this.
Side note : this should also correct the behaviour where a
<br/>
gets inserted between two<pre>
blocks following each otherDemo right below :
<code>aa
bb
outputs : (also note the
<br/>
that gets added after the second<pre>
)aa
bb
Comment #6
anders.fajerson CreditAttribution: anders.fajerson commentedI still get a br tag, both on a custom module which allows empty bodies and when erasing the body for a page content type in the db.
Comment #7
yched CreditAttribution: yched commentedfajerstarter : I don't see that myself (with that patch).
Can you provide additional info on your filters configuration ?
What are the filters (and their settings) your content goes through ?
This patch deals with a bug in the "Line break converter" filter, and AFAICS, solves it. Maybe you're experiencing a related but different bug ?
Comment #8
anders.fajerson CreditAttribution: anders.fajerson commentedI had no idea that the input format was "cached". When re-saving the input formats (standard; Filtered and full HTML) it works as advertised, took a while until I figured that out.. Can that extra step be dealt with in the patch?
Comment #9
yched CreditAttribution: yched commentedYes, it's only after replying to you and leaving home that I thought about cached filter results - sorry about that.
So, to anyone willing to test the patch : you'll have to empty your cache after applying.
PS : no, the patch itself can't deal with this - maybe it this gets in an update function could ba added to empty the cache (but I doubt it :-) or else system.install would be overcrowded by simple 'empty cache' updates).
Comment #10
Steven CreditAttribution: Steven commentedGood catch. Tested and verified. Committed to HEAD, thanks.
Comment #11
(not verified) CreditAttribution: commentedComment #12
RobRoy CreditAttribution: RobRoy commentedkilles, How about a backport? I'm running across this on 4.7.
Marked http://drupal.org/node/71927 as a dupe.
Comment #13
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedComment #14
(not verified) CreditAttribution: commented