From 969c17d82dabc9d50d0ea38775f70ecb87dd3fda Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 2 Jul 2019 03:28:03 +0000 Subject: [PATCH] Formatting: Improve performance of `wpautop()` on large paragraphs. Following [45585], older versions of PHP could segfault when attempting to autop paragraphs with 10,000+ characters. Rather than having to negative lookahead for every character in the paragraph (which could run into recursion limits), we can quickly jump ahead to the next tag and start checking from there. See #27350. git-svn-id: https://develop.svn.wordpress.org/trunk@45587 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/formatting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index 41cad82806..633085530c 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -582,7 +582,7 @@ function wpautop( $pee, $br = true ) { $pee = preg_replace( '#(<(' . $allblocksexceptp . ')[^>]*>)(((?!

|).)*)

#s', '$1$3', $pee ); // If an opening

tag is inside a block element tag, without a following closing

tag, remove it. - $pee = preg_replace( '#

(((?!

).)*)#s', '$1', $pee ); + $pee = preg_replace( '#

([^<]*(((?!

).)*))#s', '$1', $pee ); // Optionally insert line breaks. if ( $br ) {