summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/filter/filter.module3
-rw-r--r--modules/filter/filter.test4
2 files changed, 6 insertions, 1 deletions
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('!(</' . $block . '>)!', "$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', "<p>$1</p>\n", $chunk); // make paragraphs, including one at the end
+ $chunk = preg_replace('/^\n|\n\s*\n$/', '', $chunk);
+ $chunk = '<p>' . preg_replace('/\n\s*\n\n?(.)/', "</p>\n<p>$1", $chunk) . "</p>\n"; // make paragraphs, including one at the end
$chunk = preg_replace("|<p>(<li.+?)</p>|", "$1", $chunk); // problem with nested lists
$chunk = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $chunk);
$chunk = str_replace('</blockquote></p>', '</p></blockquote>', $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('<blockquote><pre>aaa</pre></blockquote>');
$this->assertEqual(substr_count($f, '<p>'), substr_count($f, '</p>'), 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.'));
}
/**