Convert line breaks into HTML (i.e.<br> and <p>) stops working after a comment.
To reproduce:
- Install drupal 7 dev, do not touch filter module.
- Create a new node using full html format
- Paste this
1- This is the first paragraph and the summary. It contains a break comment at the end.<!--break-->
2- This is the second paragraph.
3- This is the third paragraph. It should be an opening p tag at the beginning and a closing p tag at the end, in the generated source code.This issue was found by federico in #881006: Regression: 'break' tag doesn't work with Filtered HTML #16. As this is a another issue, I created this new issue.
This issue results from #559584: filter_xss() and Line break filter break HTML comments and is a bug of the line/paragraph filter.
$open = ($chunk[1] != '/' || $chunk[1] != '!'); is always true in the function _filter_autop().
Better is $open = ($chunk[1] != '/' && $chunk[1] != '!');
Changes in the patch: I've modified the filter.module and improved the tests. Note: I commented out (marked with TODO) the iframe test since it seems not useful for the line/paragraph filter. Should we treat the <iframe> tag as the other tags such as <pre> in the line break filter? Maybe this was the intention.
$chunks = preg_split('@(<!--.*?-->|</?(?:pre|script|style|object|!--)[^>]*>)@i', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
I've replaced in the tests the "found" message text with "expected" as this seems clearer.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | filter_comment_1029108_4.diff | 2.93 KB | scito |
| filter_comment_issue.diff | 2.99 KB | scito | |
| filter_comment_issue_tests_only.diff | 2.44 KB | scito |
Comments
Comment #2
scitoThe correct example for reproduction is
Comment #3
sunPlease revert.
No need to repeat the comment from the first test; this one is about comments, so either provide details on what is expected for comments, or remove the 2nd and 3rd comment line.
I'd like to see second comment in the source input that contains line breaks.
Also, you don't need to repeat the entire line in the expected string; you can do:
So needs work.
Please remove the leading "Is" from both.
Powered by Dreditor.
Comment #4
scitoI improved the patch according to your comments.
Remarks:
iframeto the$chunks. Either we add it there or we remove it from the tests since the iframe test is failing with the patched code.Comment #5
scito#1054632: Lines and paragraphs stop converting to individual p and br tags after pre tag. is a duplicate.
Comment #6
scito#1063178: Line break filter will ignore everything following a <pre>xxx</pre> is related or a duplicate.
Comment #7
damien tournoud commentedMarking as a duplicate of #1063178: Line break filter will ignore everything following a <pre>xxx</pre>, which has a proper fix (the logic around comments is totally bogus right now).