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
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | filter-comment-passthrough-828630.patch | 407 bytes | mshick |
| #13 | filter-comment-passthrough-828630.patch | 458 bytes | mshick |
| #12 | filter-comment-passthrough-828630.patch | 458 bytes | mshick |
| #8 | filter.module.patch | 371 bytes | klyphio |
Comments
Comment #1
dddave commentedMarked #842482: Line break bug as a duplicate.
Comment #2
dddave commentednarf...
Comment #3
Anonymous (not verified) commentedAs happy news, this issue is not present in Drupal 7.
Comment #4
NoRandom commentedAny 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.
Comment #5
grendzy commentedmight be a duplicate of #222926: HTML Corrector filter escapes HTML comments
Comment #6
NoRandom commentedI don't have HTML corrector active in my site and I'm experiencing this issue.
Comment #7
NoRandom commentedBug still present in 6.19.
Comment #8
klyphio commentedThere 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.
Comment #9
dddave commentedComment #11
JoshOrndorff commentedStill 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
Comment #12
mshick commentedI re-rolled the patch.
Comment #13
mshick commentedDon't use this!
I made a mistake in this patch, and am posting a proper one below.
(I would delete this if I could.)
Comment #14
mshick commentedRe-rolled the patch from #8.
Comment #15
awagner commentedThx for this patch.
Works perfectly on 6.19
Comment #16
niftyc commentedUnder 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?
Comment #17
dmitriy.trt commentedPatch 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.