From d3932e23882446f934c8a44d2f0d55121bd27771 Mon Sep 17 00:00:00 2001
From: azaozz
Date: Sun, 8 Feb 2009 16:08:02 +0000
Subject: [PATCH] Reduce backtracking in autop, fixes #6877, see #8553
git-svn-id: http://svn.automattic.com/wordpress/trunk@10527 1a063a9b-81f0-0310-95a4-ce76da25c4cd
---
wp-includes/formatting.php | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php
index 4aaa7ca47f..c730149891 100644
--- a/wp-includes/formatting.php
+++ b/wp-includes/formatting.php
@@ -131,9 +131,8 @@ function wpautop($pee, $br = 1) {
$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*?((?:div|address|form)[^>]*>)!', "
$1
$2", $pee);
- $pee = preg_replace( '||', "$1
", $pee );
+ $pee = preg_replace('|
\s*
|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace
+ $pee = preg_replace('!([^<]+)(div|address|form)>!', "
$1
$2>", $pee);
$pee = preg_replace('!\s*(?' . $allblocks . '[^>]*>)\s*
!', "$1", $pee); // don't pee all over a tag
$pee = preg_replace("|(
|", "$1", $pee); // problem with nested lists
$pee = preg_replace('|]*)>|i', "", $pee);
@@ -148,7 +147,7 @@ function wpautop($pee, $br = 1) {
$pee = preg_replace('!(?' . $allblocks . '[^>]*>)\s*
!', "$1", $pee);
$pee = preg_replace('!
(\s*?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee);
if (strpos($pee, '
)(.*?)
!is', 'clean_pre', $pee );
+ $pee = preg_replace_callback('!(]*>)(.*?)
!is', 'clean_pre', $pee );
$pee = preg_replace( "|\n
$|", '', $pee );
$pee = preg_replace('/\s*?(' . get_shortcode_regex() . ')\s*<\/p>/s', '$1', $pee); // don't auto-p wrap shortcodes that stand alone