WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/02/2019 03:28:03 AM (8 months ago)
Author:
pento
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/formatting.php

    r45586 r45587  
    583583
    584584    // If an opening <p> tag is inside a block element tag, without a following closing <p> tag, remove it.
    585     $pee = preg_replace( '#<p>(((?!</p>).)*</' . $allblocksexceptp . '>)#s', '$1', $pee );
     585    $pee = preg_replace( '#<p>([^<]*(((?!</p>).)*)</' . $allblocksexceptp . '>)#s', '$1', $pee );
    586586
    587587    // Optionally insert line breaks.
Note: See TracChangeset for help on using the changeset viewer.