Make WordPress Core

Ticket #10729: 10729.2.patch

File 10729.2.patch, 4.7 KB (added by hakre, 16 years ago)

create_function code injection security patch

  • wp-admin/page.php

     
    112112                $last_user_name = $last_user ? $last_user->display_name : __('Somebody');
    113113                $message = sprintf( __( 'Warning: %s is currently editing this page' ), esc_html( $last_user_name ) );
    114114                $message = str_replace( "'", "\'", "<div class='error'><p>$message</p></div>" );
    115                 add_action('admin_notices', create_function( '', "echo '$message';" ) );
     115                add_action('admin_notices', create_function( "\$message = '$message'", 'echo $message;' ) );
    116116        } else {
    117117                wp_set_post_lock( $post->ID );
    118118                wp_enqueue_script('autosave');
  • wp-admin/post.php

     
    147147                $last_user_name = $last_user ? $last_user->display_name : __('Somebody');
    148148                $message = sprintf( __( 'Warning: %s is currently editing this post' ), esc_html( $last_user_name ) );
    149149                $message = str_replace( "'", "\'", "<div class='error'><p>$message</p></div>" );
    150                 add_action('admin_notices', create_function( '', "echo '$message';" ) );
     150                add_action('admin_notices', create_function( "\$html = '$message'", 'echo $html;' ) );
    151151        } else {
    152152                wp_set_post_lock( $post->ID );
    153153                wp_enqueue_script('autosave');
  • wp-includes/pomo/po.php

     
    146146         * @param string $with prepend lines with this string
    147147         */
    148148        function prepend_each_line($string, $with) {
     149                // FIXME codeinjection is possible here, this needs to be changed
    149150                $php_with = var_export($with, true);
    150151                $lines = explode("\n", $string);
    151152                // do not prepend the string on the last empty line, artefact by explode
    152153                if ("\n" == substr($string, -1)) unset($lines[count($lines) - 1]);
    153                 $res = implode("\n", array_map(create_function('$x', "return $php_with.\$x;"), $lines));
     154                // FIXME codeinjection is done actually here
     155                $res = implode("\n", array_map(create_function('$x, $pre = ""', "return $php_with.\$x;"), $lines));
    154156                // give back the empty line, we ignored above
    155157                if ("\n" == substr($string, -1)) $res .= "\n";
    156158                return $res;
  • wp-includes/formatting.php

     
    26202620function links_add_base_url( $content, $base, $attrs = array('src', 'href') ) {
    26212621        $attrs = implode('|', (array)$attrs);
    26222622        return preg_replace_callback("!($attrs)=(['\"])(.+?)\\2!i",
    2623                         create_function('$m', 'return _links_add_base($m, "' . $base . '");'),
     2623                        create_function('$m, $base = ". $base ."', 'return _links_add_base($m, $base);'),
    26242624                        $content);
    26252625}
    26262626
     
    26612661function links_add_target( $content, $target = '_blank', $tags = array('a') ) {
    26622662        $tags = implode('|', (array)$tags);
    26632663        return preg_replace_callback("!<($tags)(.+?)>!i",
    2664                         create_function('$m', 'return _links_add_target($m, "' . $target . '");'),
     2664                        create_function('$m, $target="' . $target . '"', 'return _links_add_target($m, $target);'),
    26652665                        $content);
    26662666}
    26672667/**
  • wp-includes/gettext.php

     
    346346                        $func_body = "
    347347                                \$plural = ($expression);
    348348                                return (\$plural <= $nplurals)? \$plural : \$plural - 1;";
     349                        // FIXME might be prone to code injection
    349350                        $this->select_string_function = create_function('$n', $func_body);
    350351                }
    351352                return call_user_func($this->select_string_function, $n);
  • wp-includes/theme.php

     
    886886        if ( validate_file($_GET['template']) )
    887887                return;
    888888
    889         add_filter( 'template', create_function('', "return '{$_GET['template']}';") );
     889        add_filter( 'template', create_function("\$template = '{$_GET['template']}'", "return $template;") );
    890890
    891891        if ( isset($_GET['stylesheet']) ) {
    892892                $_GET['stylesheet'] = preg_replace('|[^a-z0-9_./-]|i', '', $_GET['stylesheet']);
    893893                if ( validate_file($_GET['stylesheet']) )
    894894                        return;
    895                 add_filter( 'stylesheet', create_function('', "return '{$_GET['stylesheet']}';") );
     895                add_filter( 'stylesheet', create_function("\$stylesheet = '{$_GET['stylesheet']}'", "return $stylesheet;") );
    896896        }
    897897
    898898        // Prevent theme mods to current theme being used on theme being previewed