? autop-pcre-limit.patch
? autop-pcre-limit_0.patch
? sites/default/files
? sites/default/settings.php
Index: modules/filter/filter.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v
retrieving revision 1.244
diff -u -p -r1.244 filter.module
--- modules/filter/filter.module	15 Mar 2009 01:53:16 -0000	1.244
+++ modules/filter/filter.module	26 Mar 2009 11:54:21 -0000
@@ -918,7 +918,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/', '', $chunk);
+      $chunk = '<p>' . preg_replace('/\n\s*\n\n?(.)/', "</p>\n<p>$1", $chunk) . '</p>'; // 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);
Index: modules/filter/filter.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.test,v
retrieving revision 1.16
diff -u -p -r1.16 filter.test
--- modules/filter/filter.test	15 Mar 2009 01:53:16 -0000	1.16
+++ modules/filter/filter.test	26 Mar 2009 11:54:21 -0000
@@ -208,6 +208,10 @@ class FilterTestCase extends DrupalWebTe
 
     $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.'));
   }
 
   /**
