From 44c170459e6e4cc1f4439f14d31142a3e13d9f66 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Mon, 20 Oct 2008 19:25:02 +0000 Subject: [PATCH] Reduce backtracking in wpautop. fixes #6877 git-svn-id: https://develop.svn.wordpress.org/trunk@9255 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/formatting.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 71dfc84071..5192d95b95 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -126,7 +126,11 @@ function wpautop($pee, $br = 1) { $pee = preg_replace('|\s*\s*|', '', $pee); } $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates - $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "

$1

\n", $pee); // make paragraphs, including one at the end + // make paragraphs, including one at the end + $pees = preg_split('/\n\s*\n/', $pee, -1, PREG_SPLIT_NO_EMPTY); + $pee = ''; + foreach ( $pees as $tinkle ) + $pee .= '

' . trim($tinkle, "\n") . "

\n"; $pee = preg_replace('|

\s*?

|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace $pee = preg_replace('!

([^<]+)\s*?(]*>)!', "

$1

$2", $pee); $pee = preg_replace( '|

|', "$1

", $pee );