From 3e9d39b667157ba7c2804c45e42468a4c8aaecca Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 20 Oct 2008 19:25:02 +0000 Subject: [PATCH] Reduce backtracking in wpautop. fixes #6877 git-svn-id: http://svn.automattic.com/wordpress/trunk@9255 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- 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 );