Make WordPress Core

Changeset 10339


Ignore:
Timestamp:
01/09/2009 07:29:35 PM (18 years ago)
Author:
ryan
Message:

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

Location:
trunk
Files:
8 edited

Legend:

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

    r9933 r10339  
    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);
  • trunk/wp-admin/import/blogware.php

    r9903 r10339  
    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);
  • trunk/wp-admin/import/livejournal.php

    r10334 r10339  
    7272
    7373                        // Clean up content
    74                         $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content);
     74                        $post_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $post_content);
    7575                        $post_content = str_replace('<br>', '<br />', $post_content);
    7676                        $post_content = str_replace('<hr>', '<hr />', $post_content);
     
    108108
    109109                                        // Clean up content
    110                                         $comment_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $comment_content);
     110                                        $comment_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $comment_content);
    111111                                        $comment_content = str_replace('<br>', '<br />', $comment_content);
    112112                                        $comment_content = str_replace('<hr>', '<hr />', $comment_content);
  • trunk/wp-admin/import/rss.php

    r9903 r10339  
    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);
  • trunk/wp-admin/import/wordpress.php

    r10157 r10339  
    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);
  • trunk/wp-includes/formatting.php

    r10322 r10339  
    13181318        } else {
    13191319                $subject = str_replace('_', ' ', $matches[2]);
    1320                 /** @todo use preg_replace_callback() */
    1321                 $subject = preg_replace('#\=([0-9a-f]{2})#ei', "chr(hexdec(strtolower('$1')))", $subject);
     1320                $subject = preg_replace_callback('#\=([0-9a-f]{2})#i', create_function('$match', 'return chr(hexdec(strtolower($match[1])));'), $subject);
    13221321                return $subject;
    13231322        }
  • trunk/wp-includes/kses.php

    r10150 r10339  
    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;
  • trunk/wp-includes/post-template.php

    r10269 r10339  
    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.