The line break converter filter as of Drupal 6.17 is failing to handle HTML comments properly. HTML comments like <!-- please ignore this --> are being doubled up. HTML comments which are inside a paragraph -- inline sort of -- cause the paragraph to be split in two paragraphs and thus an unwanted line break is introduced. I experience this problem on all of the 6.17 Drupal systems I am maintaining, which are vastly different in age, configuration, and underlying operating system and PHP version.

To reproduce the problem simply add an HTML comment into the body -- like in the example below --, select an input format with line break converter and without HTML filter, normally "Full HTML", and look at the source of the page created.

Body text:


Ultrices odio et sed, integer, cum, pulvinar cras nunc proin nec pulvinar, augue non diam magna! Ultrices velit purus <!-- leave me alone --> elementum dictumst, scelerisque, amet tristique amet non enim pellentesque ac sit, sagittis dis pulvinar cursus ac etiam, a dignissim porttitor integer.

becomes browser source code:


<p>Ultrices odio et sed, integer, cum, pulvinar cras nunc proin nec pulvinar, augue non diam magna! Ultrices velit purus </p> 
<!-- leave me alone --><!-- leave me alone --><p> elementum dictumst, scelerisque, amet tristique amet non enim pellentesque ac sit, sagittis dis pulvinar cursus ac etiam, a dignissim porttitor integer.</p>

This behavior introduces unwanted line breaks, and is a nuisance when HTML comments are being further processed like being replaced by something else.

Why are HTML comments not ignored by the line break converter as it used to be?

This may or may not be related/caused by the change discussed at http://drupal.org/node/133188

Comments

dddave’s picture

Status: Active » Closed (duplicate)

Marked #842482: Line break bug as a duplicate.

dddave’s picture

Status: Closed (duplicate) » Active

narf...

Anonymous’s picture

As happy news, this issue is not present in Drupal 7.

NoRandom’s picture

Any news about this bug? Have you, hd, tested if the patch at http://drupal.org/node/133188 also solves the problem with double html comments?

Regards.

grendzy’s picture

NoRandom’s picture

I don't have HTML corrector active in my site and I'm experiencing this issue.

NoRandom’s picture

Version: 6.17 » 6.19

Bug still present in 6.19.

klyphio’s picture

StatusFileSize
new371 bytes

There was code added to the filter module to ensure that comments in the code would make it into the final code.

For me, the problem is the fact that the comments were being doubled up, which was a problem when javascript blocks were surrounded by comment marks which meant that javascript blocks would appear twice.

The attached patch only ensures that the comment sections only appear once. It's a simple patch - it adds a missing "continue" statement to ensure that the comments aren't added to the output twice.

dddave’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, filter.module.patch, failed testing.

JoshOrndorff’s picture

Version: 6.19 » 6.20

Still happening in 6.20 I could re-roll the last patch, but if I understand correctly, it only solves the problem of duplicating the comment in the final markup, and does not solve the problem of splitting paragraphs.

Since this is apparently not a problem in Drupal seven, could we identify what is different in the code there?

-Josh

mshick’s picture

StatusFileSize
new458 bytes

I re-rolled the patch.

mshick’s picture

Status: Needs work » Patch (to be ported)
StatusFileSize
new458 bytes

Don't use this!

I made a mistake in this patch, and am posting a proper one below.

(I would delete this if I could.)

mshick’s picture

StatusFileSize
new407 bytes

Re-rolled the patch from #8.

awagner’s picture

Thx for this patch.

Works perfectly on 6.19

niftyc’s picture

Version: 6.20 » 6.22

Under 6.22 I have this problem and the patches here do not correct the issue, I am still getting double HTML comments.

Worse, it looks like some recent-ish versions of firefox will treat a double comment as a desire to show the comment to the user.

Any advice?

dmitriy.trt’s picture

Version: 6.22 » 6.x-dev
Status: Patch (to be ported) » Reviewed & tested by the community

Patch from #14 can be applied to current git code in 6.x branch and it fixes the problem with duplicate comments.

The bug causes duplicate sidebars generated by the Contextly module (it uses HTML comments to put sidebars into the text), so the bug is not harmless.

Status: Reviewed & tested by the community » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.