diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-05-24 19:12:12 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-05-24 19:12:12 +0000 |
commit | df6c6465fdf4b9de5fdd7845429f4e086531dbee (patch) | |
tree | c8fa968083a516e1e64add036795436388a02072 /modules | |
parent | a24a6c2bba2d15ab835e0b0fce9354bb6fb16c5b (diff) | |
download | brdo-df6c6465fdf4b9de5fdd7845429f4e086531dbee.tar.gz brdo-df6c6465fdf4b9de5fdd7845429f4e086531dbee.tar.bz2 |
- Patch #133188 by John Morahan, frega: make sure that long string are line-break-ed correctly.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/filter/filter.module | 3 | ||||
-rw-r--r-- | modules/filter/filter.test | 4 |
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.')); } /** |