From 2143e4d3729ea2afe918545d80fc2d75d3e89485 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 19 Feb 2011 00:29:40 +0000 Subject: - Patch #1063178 by Haza: line break filter will ignore everything following a
xxx
. --- modules/filter/filter.module | 20 +++++++++++++------- modules/filter/filter.test | 21 ++++++++++++++++++++- 2 files changed, 33 insertions(+), 8 deletions(-) (limited to 'modules') diff --git a/modules/filter/filter.module b/modules/filter/filter.module index 24c64bd55..d66826b29 100644 --- a/modules/filter/filter.module +++ b/modules/filter/filter.module @@ -1590,11 +1590,12 @@ function _filter_autop($text) { // All block level tags $block = '(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|p|h[1-6]|hr)'; - // Split at opening and closing PRE, SCRIPT, STYLE, OBJECT tags and comments. - // We don't apply any processing to the contents of these tags to avoid messing - // up code. We look for matched pairs and allow basic nesting. For example: + // Split at opening and closing PRE, SCRIPT, STYLE, OBJECT, IFRAME tags + // and comments. We don't apply any processing to the contents of these tags + // to avoid messing up code. We look for matched pairs and allow basic + // nesting. For example: // "processed
 ignored  ignored 
processed" - $chunks = preg_split('@(|]*>)@i', $text, -1, PREG_SPLIT_DELIM_CAPTURE); + $chunks = preg_split('@(|]*>)@i', $text, -1, PREG_SPLIT_DELIM_CAPTURE); // Note: PHP ensures the array consists of alternating delimiters and literals // and begins and ends with a literal (inserting NULL as required). $ignore = FALSE; @@ -1602,9 +1603,14 @@ function _filter_autop($text) { $output = ''; foreach ($chunks as $i => $chunk) { if ($i % 2) { - // Opening or closing tag? - $open = ($chunk[1] != '/' || $chunk[1] != '!'); $comment = (substr($chunk, 0, 4) == '\n\nbbb\n\nccc\n\nddd\n\neee\n\nfff" => array( + "

aaa

\n

\nbbb

\n

ccc

\n

ddd

" => TRUE, + "

\neee

\n

fff

" => TRUE, + ), + // Check that a comment in a PRE will result that the text after + // the comment, but still in PRE, is not transformed. + "
aaa\nbbb\n\nccc
\nddd" => array( + "
aaa\nbbb\n\nccc
" => TRUE, + ), + // Bug 810824, paragraphs were appearing around iframe tags. + "\n\n" => array( + "

" => FALSE, + ), ); $this->assertFilteredString($filter, $tests); @@ -1464,7 +1483,7 @@ www.example.com with a newline in comments --> if (!$success) { $this->verbose('Source:
' . check_plain(var_export($source, TRUE)) . '
' . '
' . 'Result:
' . check_plain(var_export($result, TRUE)) . '
' - . '
' . ($is_expected ? 'Found:' : 'Not found:') + . '
' . ($is_expected ? 'Expected:' : 'Not expected:') . '
' . check_plain(var_export($value, TRUE)) . '
' ); } -- cgit v1.2.3