From 1d14b0f894b68c986f9380de398988502cc2002d Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 28 Dec 2008 19:30:36 +0000 Subject: [PATCH] - Patch #212236 by wrwrwr: automatic line breaking sometimes results in an unpaired end of paragraph tag. --- modules/filter/filter.module | 2 +- modules/filter/filter.test | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/filter/filter.module b/modules/filter/filter.module index ae07a624831..c0196c07a95 100644 --- a/modules/filter/filter.module +++ b/modules/filter/filter.module @@ -897,10 +897,10 @@ function _filter_autop($text) { $chunk = preg_replace('!()!', "$1\n\n", $chunk); // Space things out a little $chunk = preg_replace("/\n\n+/", "\n\n", $chunk); // take care of duplicates $chunk = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "

$1

\n", $chunk); // make paragraphs, including one at the end - $chunk = preg_replace('|

\s*

\n|', '', $chunk); // under certain strange conditions it could create a P of entirely whitespace $chunk = preg_replace("|

(|", "$1", $chunk); // problem with nested lists $chunk = preg_replace('|

]*)>|i', "

", $chunk); $chunk = str_replace('

', '

', $chunk); + $chunk = preg_replace('|

\s*

\n?|', '', $chunk); // under certain strange conditions it could create a P of entirely whitespace $chunk = preg_replace('!

\s*(]*>)!', "$1", $chunk); $chunk = preg_replace('!(]*>)\s*

!', "$1", $chunk); $chunk = preg_replace('|(?)\s*\n|', "
\n", $chunk); // make line breaks diff --git a/modules/filter/filter.test b/modules/filter/filter.test index 3015bf91e37..48444ebcb50 100644 --- a/modules/filter/filter.test +++ b/modules/filter/filter.test @@ -200,7 +200,14 @@ class FilterTestCase extends DrupalWebTestCase { * Test the line break filter */ function testLineBreakFilter() { + $f = _filter_autop('

'); + $this->assertEqual(substr_count($f, '

'), substr_count($f, '

'), t('Make sure line breaking produces matching paragraph tags.')); + + $f = _filter_autop('

'); + $this->assertEqual(substr_count($f, '

'), substr_count($f, '

'), t('Make sure line breaking produces matching paragraph tags.')); + $f = _filter_autop('
aaa
'); + $this->assertEqual(substr_count($f, '

'), substr_count($f, '

'), t('Make sure line breaking produces matching paragraph tags.')); } /**