WordPress.org

Make WordPress Core

Changeset 10392


Ignore:
Timestamp:
01/21/09 18:51:48 (6 years ago)
Author:
ryan
Message:

Use preg_replace_callback instead of preg_replace with eval. Props beaulebens. see #8689 for 2.7

Location:
branches/2.7
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/2.7/wp-admin/import/blogger.php

    r9933 r10392  
    551551 
    552552        // Clean up content 
    553         $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content); 
     553        $post_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $post_content); 
    554554        $post_content = str_replace('<br>', '<br />', $post_content); 
    555555        $post_content = str_replace('<hr>', '<hr />', $post_content); 
     
    604604 
    605605        // Clean up content 
    606         $comment_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $comment_content); 
     606        $comment_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $comment_content); 
    607607        $comment_content = str_replace('<br>', '<br />', $comment_content); 
    608608        $comment_content = str_replace('<hr>', '<hr />', $comment_content); 
  • branches/2.7/wp-admin/import/blogware.php

    r9903 r10392  
    9090 
    9191            // Clean up content 
    92             $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content); 
     92            $post_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $post_content); 
    9393            $post_content = str_replace('<br>', '<br />', $post_content); 
    9494            $post_content = str_replace('<hr>', '<hr />', $post_content); 
     
    130130 
    131131                    // Clean up content 
    132                     $comment_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $comment_content); 
     132                    $comment_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $comment_content); 
    133133                    $comment_content = str_replace('<br>', '<br />', $comment_content); 
    134134                    $comment_content = str_replace('<hr>', '<hr />', $comment_content); 
  • branches/2.7/wp-admin/import/livejournal.php

    r9903 r10392  
    7171 
    7272            // Clean up content 
    73             $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content); 
     73            $post_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $post_content); 
    7474            $post_content = str_replace('<br>', '<br />', $post_content); 
    7575            $post_content = str_replace('<hr>', '<hr />', $post_content); 
     
    107107 
    108108                    // Clean up content 
    109                     $comment_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $comment_content); 
     109                    $comment_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $comment_content); 
    110110                    $comment_content = str_replace('<br>', '<br />', $comment_content); 
    111111                    $comment_content = str_replace('<hr>', '<hr />', $comment_content); 
  • branches/2.7/wp-admin/import/rss.php

    r9903 r10392  
    104104 
    105105            // Clean up content 
    106             $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content); 
     106            $post_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $post_content); 
    107107            $post_content = str_replace('<br>', '<br />', $post_content); 
    108108            $post_content = str_replace('<hr>', '<hr />', $post_content); 
  • branches/2.7/wp-admin/import/wordpress.php

    r10157 r10392  
    382382 
    383383        $post_excerpt = $this->get_tag( $post, 'excerpt:encoded' ); 
    384         $post_excerpt = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_excerpt); 
     384        $post_excerpt = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $post_excerpt); 
    385385        $post_excerpt = str_replace('<br>', '<br />', $post_excerpt); 
    386386        $post_excerpt = str_replace('<hr>', '<hr />', $post_excerpt); 
    387387 
    388388        $post_content = $this->get_tag( $post, 'content:encoded' ); 
    389         $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content); 
     389        $post_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $post_content); 
    390390        $post_content = str_replace('<br>', '<br />', $post_content); 
    391391        $post_content = str_replace('<hr>', '<hr />', $post_content); 
  • branches/2.7/wp-includes/formatting.php

    r10391 r10392  
    13061306    } else { 
    13071307        $subject = str_replace('_', ' ', $matches[2]); 
    1308         /** @todo use preg_replace_callback() */ 
    1309         $subject = preg_replace('#\=([0-9a-f]{2})#ei', "chr(hexdec(strtolower('$1')))", $subject); 
     1308        $subject = preg_replace_callback('#\=([0-9a-f]{2})#i', create_function('$match', 'return chr(hexdec(strtolower($match[1])));'), $subject); 
    13101309        return $subject; 
    13111310    } 
  • branches/2.7/wp-includes/kses.php

    r10150 r10392  
    395395 */ 
    396396function wp_kses_split($string, $allowed_html, $allowed_protocols) { 
    397     return preg_replace('%((<!--.*?(-->|$))|(<[^>]*(>|$)|>))%e', 
    398     "wp_kses_split2('\\1', \$allowed_html, ".'$allowed_protocols)', $string); 
     397    global $pass_allowed_html, $pass_allowed_protocols; 
     398    $pass_allowed_html = $allowed_html; 
     399    $pass_allowed_protocols = $allowed_protocols; 
     400    return preg_replace_callback('%((<!--.*?(-->|$))|(<[^>]*(>|$)|>))%', 
     401        create_function('$match', 'global $pass_allowed_html, $pass_allowed_protocols; return wp_kses_split2($match[1], $pass_allowed_html, $pass_allowed_protocols);'), $string); 
    399402} 
    400403 
     
    10001003 */ 
    10011004function wp_kses_decode_entities($string) { 
    1002     $string = preg_replace('/&#([0-9]+);/e', 'chr("\\1")', $string); 
    1003     $string = preg_replace('/&#[Xx]([0-9A-Fa-f]+);/e', 'chr(hexdec("\\1"))', $string); 
     1005    $string = preg_replace_callback('/&#([0-9]+);/', create_function('$match', 'return chr($match[1]);'), $string); 
     1006    $string = preg_replace_callback('/&#[Xx]([0-9A-Fa-f]+);/', create_function('$match', 'return chr(hexdec($match[1]));'), $string); 
    10041007 
    10051008    return $string; 
  • branches/2.7/wp-includes/post-template.php

    r10270 r10392  
    224224    } 
    225225    if ( $preview ) // preview fix for javascript bug with foreign languages 
    226         $output =   preg_replace('/\%u([0-9A-F]{4,4})/e',   "'&#'.base_convert('\\1',16,10).';'", $output); 
     226        $output =   preg_replace_callback('/\%u([0-9A-F]{4})/', create_function('$match', 'return "&#" . base_convert($match[1], 16, 10) . ";";'), $output); 
    227227 
    228228    return $output; 
Note: See TracChangeset for help on using the changeset viewer.