When adding a node with some <pre></pre> inside, we don't have any more line break for everything that follow those pre.

How to reproduce :
- In Text filter, be sure to have Convert line breaks into HTML enabled
- Add a new node with a text like that in the body

aaa

<pre>bbb</pre>

ccc
bbb

What we expected :
This should be displayed as

<p>aaa</p> 
<pre>bbb</pre><p> 
ccc<br /> 
bbb</p> 

What we currently have :
Right now, this is the output

<p>aaa</p> 
<pre>bbb</pre> 
 
ccc
bbb
CommentFileSizeAuthor
#11 1063178_3.patch4.08 KBhaza
#8 1063178_2.patch3.92 KBhaza
#3 1063178.patch2.28 KBhaza
#1 1063178.test.patch572 byteshaza

Comments

haza’s picture

StatusFileSize
new572 bytes

Added a test case in filter module to test this.

haza’s picture

Status: Active » Needs review
haza’s picture

StatusFileSize
new2.28 KB

And here is the patch (including tests) for this issue

damien tournoud’s picture

scito’s picture

damien tournoud’s picture

Status: Needs review » Needs work

Marked #1029108: Comments confuse line/paragraph filter and #1054632: Lines and paragraphs stop converting to individual p and br tags after pre tag. because those two fail to realize that the logic around comments is currently completely bogus: a comment will reset the ignore mode so any comment in a <pre> tag for example would make the text after the comment replaced for paragraphs.

So needs work here for:

sun’s picture

Why do we fiddle with IFRAMEs here though? That's tackled in #810824: Line break filter adds paragraphs around <iframe> elements already.

haza’s picture

Status: Needs work » Needs review
StatusFileSize
new3.92 KB

Rework patch with the feedbacks from DamZ

damien tournoud’s picture

Status: Needs review » Needs work

The hunk about the iframe is necessary because we have a test for it:

      // Skip contents of certain block tags entirely.
      "<script>aaa\nbbb\n\nccc</script>
<style>aaa\nbbb\n\nccc</style>
<pre>aaa\nbbb\n\nccc</pre>
<object>aaa\nbbb\n\nccc</object>
<iframe>aaa\nbbb\n\nccc</iframe>
" => array(
        "<script>aaa\nbbb\n\nccc</script>" => TRUE,
        "<style>aaa\nbbb\n\nccc</style>" => TRUE,
        "<pre>aaa\nbbb\n\nccc</pre>" => TRUE,
        "<object>aaa\nbbb\n\nccc</object>" => TRUE,
        "<iframe>aaa\nbbb\n\nccc</iframe>" => TRUE,
      ),

The test currently passes because of this bug (anything after the first <script> will be ignored by the line break filter anyway).

damien tournoud’s picture

Status: Needs work » Needs review

Cross post.

haza’s picture

StatusFileSize
new4.08 KB

Fixing some typo, and added test from #810824: Line break filter adds paragraphs around <iframe> elements on DamZ request

damien tournoud’s picture

This looks good to me.

Quick summary: this patch fixes the comment handling logic introduced by #559584: filter_xss() and Line break filter break HTML comments. When the line-break filter bumps into a comment, it should just ignore it. Comments should not affect the state of the line-break filter, and should have no effect on whether or not the line-break filter should process content before or after the comment.

Two related changes are in the patch:

  • adding <iframe> to the list of ignored elements: we had a test for it, but it was only passing because of this bug
  • a cosmetic fix to the verbose output of the filter test, already vetted by Sun in #1029108: Comments confuse line/paragraph filter

This looks ready to go in for me, but I worked with Haza on that patch, so I will wait for someone else to RTBC.

sun’s picture

Status: Needs review » Reviewed & tested by the community

Yup, ready to fly.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

yched’s picture

I've also seen this behavior on d.o after

tags. Dunno if this is related - and if it is, if it should be backported ?

damien tournoud’s picture

It seems that the line break filter diverged between D6 and D7. This was not supposed to happen...

yched’s picture

Grr. My #15 should have read :

I've also seen this behavior on d.o after <code> tags. Dunno if this is related - and if it is, if it should be backported ?

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

agileware’s picture

For people searching the issue queue for bugs it helpful to mention that this fix fixes the following bug also:

The teaser <!--break--> comment tag breaks the 'Convert line breaks into HTML (i.e. <br> and <p>)' filter.