Don't strip slashes from pre. Props DelGurth and mdawaffe. fixes #2059

git-svn-id: http://svn.automattic.com/wordpress/trunk@6102 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-09-13 04:11:21 +00:00
parent b9dcf3c0c3
commit 7bbd23f3c6
1 changed files with 10 additions and 2 deletions

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;