Changeset 6102

Show
Ignore:
Timestamp:
09/13/07 04:11:21 (1 year ago)
Author:
ryan
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-includes/formatting.php

    r6096 r6102  
    4545} 
    4646 
    47 function clean_pre($text) { 
     47// Accepts matches array from preg_replace_callback in wpautop() 
     48// or a string 
     49function clean_pre($matches) { 
     50    if ( is_array($matches) ) 
     51        $text = $matches[1] . $matches[2] . "</pre>"; 
     52    else 
     53        $text = $matches; 
     54 
    4855    $text = str_replace('<br />', '', $text); 
    4956    $text = str_replace('<p>', "\n", $text); 
    5057    $text = str_replace('</p>', '', $text); 
     58 
    5159    return $text; 
    5260} 
     
    7987    $pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee); 
    8088    if (strpos($pee, '<pre') !== false) 
    81         $pee = preg_replace('!(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') .  stripslashes(clean_pre('$2'))  . '</pre>' ", $pee); 
     89        $pee = preg_replace_callback('!(<pre.*?>)(.*?)</pre>!is', 'clean_pre', $pee ); 
    8290    $pee = preg_replace( "|\n</p>$|", '</p>', $pee ); 
    8391