Make WordPress Core

Changeset 6102


Ignore:
Timestamp:
09/13/2007 04:11:21 AM (17 years ago)
Author:
ryan
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.