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
This commit is contained in:
Ryan Boren 2007-09-13 04:11:21 +00:00
parent 7ae0df4b21
commit e0b73aa55a

View File

@ -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] . "</pre>";
else
$text = $matches;
$text = str_replace('<br />', '', $text);
$text = str_replace('<p>', "\n", $text);
$text = str_replace('</p>', '', $text);
return $text;
}
@ -78,7 +86,7 @@ function wpautop($pee, $br = 1) {
$pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*<br />!', "$1", $pee);
$pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee);
if (strpos($pee, '<pre') !== false)
$pee = preg_replace('!(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') . stripslashes(clean_pre('$2')) . '</pre>' ", $pee);
$pee = preg_replace_callback('!(<pre.*?>)(.*?)</pre>!is', 'clean_pre', $pee );
$pee = preg_replace( "|\n</p>$|", '</p>', $pee );
return $pee;