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. Built from https://develop.svn.wordpress.org/trunk@45587 git-svn-id: http://core.svn.wordpress.org/trunk@45398 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -582,7 +582,7 @@ function wpautop( $pee, $br = true ) {
|
||||
$pee = preg_replace( '#(<(' . $allblocksexceptp . ')[^>]*>)(((?!<p>|</\2>).)*)</p>#s', '$1$3', $pee );
|
||||
|
||||
// If an opening <p> tag is inside a block element tag, without a following closing <p> tag, remove it.
|
||||
$pee = preg_replace( '#<p>(((?!</p>).)*</' . $allblocksexceptp . '>)#s', '$1', $pee );
|
||||
$pee = preg_replace( '#<p>([^<]*(((?!</p>).)*)</' . $allblocksexceptp . '>)#s', '$1', $pee );
|
||||
|
||||
// Optionally insert line breaks.
|
||||
if ( $br ) {
|
||||
|
||||
Reference in New Issue
Block a user