From df6c6465fdf4b9de5fdd7845429f4e086531dbee Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 24 May 2009 19:12:12 +0000 Subject: - Patch #133188 by John Morahan, frega: make sure that long string are line-break-ed correctly. --- modules/filter/filter.module | 3 ++- modules/filter/filter.test | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/filter/filter.module b/modules/filter/filter.module index 625c28711..45c2b14e5 100644 --- a/modules/filter/filter.module +++ b/modules/filter/filter.module @@ -894,7 +894,8 @@ function _filter_autop($text) { $chunk = preg_replace('!(<' . $block . '[^>]*>)!', "\n$1", $chunk); // Space things out a little $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('/^\n|\n\s*\n$/', '', $chunk); + $chunk = '

' . preg_replace('/\n\s*\n\n?(.)/', "

\n

$1", $chunk) . "

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

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

]*)>|i', "

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

', '

', $chunk); diff --git a/modules/filter/filter.test b/modules/filter/filter.test index 86e1e556a..3c13cc56d 100644 --- a/modules/filter/filter.test +++ b/modules/filter/filter.test @@ -208,6 +208,10 @@ class FilterTestCase extends DrupalWebTestCase { $f = _filter_autop('
aaa
'); $this->assertEqual(substr_count($f, '

'), substr_count($f, '

'), t('Make sure line breaking produces matching paragraph tags.')); + + $limit = max(ini_get('pcre.backtrack_limit'), ini_get('pcre.recursion_limit')); + $f = _filter_autop($this->randomName($limit)); + $this->assertNotEqual($f, '', t('Make sure line breaking can process long strings.')); } /** -- cgit v1.2.3