From e0b73aa55ad06ef005b9f21d2b7c1140c24fe7f8 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Thu, 13 Sep 2007 04:11:21 +0000 Subject: [PATCH] Don't strip slashes from pre. Props DelGurth and mdawaffe. fixes #2059 git-svn-id: https://develop.svn.wordpress.org/trunk@6102 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/formatting.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 1b6b7feb97..5e19a02475 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -44,10 +44,18 @@ function wptexturize($text) { return $output; } -function clean_pre($text) { +// Accepts matches array from preg_replace_callback in wpautop() +// or a string +function clean_pre($matches) { + if ( is_array($matches) ) + $text = $matches[1] . $matches[2] . ""; + else + $text = $matches; + $text = str_replace('
', '', $text); $text = str_replace('

', "\n", $text); $text = str_replace('

', '', $text); + return $text; } @@ -78,7 +86,7 @@ function wpautop($pee, $br = 1) { $pee = preg_replace('!(]*>)\s*
!', "$1", $pee); $pee = preg_replace('!
(\s*]*>)!', '$1', $pee); if (strpos($pee, ')(.*?)!ise', " stripslashes('$1') . stripslashes(clean_pre('$2')) . '' ", $pee); + $pee = preg_replace_callback('!()(.*?)!is', 'clean_pre', $pee ); $pee = preg_replace( "|\n

$|", '

', $pee ); return $pee;