Make WordPress Core

Changeset 24475


Ignore:
Timestamp:
06/21/2013 05:55:56 AM (13 years ago)
Author:
nacin
Message:

More robust escaping in the plugin/theme upgrader.

Merges [24474] to the 3.5 branch.

Location:
branches/3.5
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/3.5

  • branches/3.5/wp-admin/includes/class-wp-upgrader.php

    r22019 r24475  
    9999                                default:
    100100                                        if ( ! $wp_filesystem->find_folder($dir) )
    101                                                 return new WP_Error('fs_no_folder', sprintf($this->strings['fs_no_folder'], $dir));
     101                                                return new WP_Error( 'fs_no_folder', sprintf( $this->strings['fs_no_folder'], esc_html( basename( $dir ) ) ) );
    102102                                        break;
    103103                        }
     
    11341134                        foreach ( $errors->get_error_messages() as $message ) {
    11351135                                if ( $errors->get_error_data() )
    1136                                         $this->feedback($message . ' ' . $errors->get_error_data() );
     1136                                        $this->feedback($message . ' ' . esc_html( $errors->get_error_data() ) );
    11371137                                else
    11381138                                        $this->feedback($message);
     
    11481148                        $args = func_get_args();
    11491149                        $args = array_splice($args, 1);
    1150                         if ( !empty($args) )
     1150                        if ( $args ) {
     1151                                $args = array_map( 'strip_tags', $args );
     1152                                $args = array_map( 'esc_html', $args );
    11511153                                $string = vsprintf($string, $args);
     1154                        }
    11521155                }
    11531156                if ( empty($string) )
     
    11891192                $this->plugin = $this->upgrader->plugin_info();
    11901193                if ( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){
    1191                         echo '<iframe style="border:0;overflow:hidden" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&networkwide=' . $this->plugin_network_active . '&plugin=' . $this->plugin, 'activate-plugin_' . $this->plugin) .'"></iframe>';
     1194                        echo '<iframe style="border:0;overflow:hidden" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&networkwide=' . $this->plugin_network_active . '&plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin) .'"></iframe>';
    11921195                }
    11931196
    11941197                $update_actions =  array(
    1195                         'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $this->plugin, 'activate-plugin_' . $this->plugin) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>',
     1198                        'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>',
    11961199                        'plugins_page' => '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Go to plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>'
    11971200                );
     
    12451248                        $args = func_get_args();
    12461249                        $args = array_splice($args, 1);
    1247                         if ( !empty($args) )
     1250                        if ( $args ) {
     1251                                $args = array_map( 'strip_tags', $args );
     1252                                $args = array_map( 'esc_html', $args );
    12481253                                $string = vsprintf($string, $args);
     1254                        }
    12491255                }
    12501256                if ( empty($string) )
     
    12701276                        foreach ( $error->get_error_messages() as $emessage ) {
    12711277                                if ( $error->get_error_data() )
    1272                                         $messages[] = $emessage . ' ' . $error->get_error_data();
     1278                                        $messages[] = $emessage . ' ' . esc_html( $error->get_error_data() );
    12731279                                else
    12741280                                        $messages[] = $emessage;
     
    14311437
    14321438                if ( 'import' == $from )
    1433                         $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;from=import&amp;plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin &amp; Run Importer') . '</a>';
     1439                        $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;from=import&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin &amp; Run Importer') . '</a>';
    14341440                else
    1435                         $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>';
     1441                        $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>';
    14361442
    14371443                if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
    1438                         $install_actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;networkwide=1&amp;plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin for all sites in this network') . '" target="_parent">' . __('Network Activate') . '</a>';
     1444                        $install_actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;networkwide=1&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin for all sites in this network') . '" target="_parent">' . __('Network Activate') . '</a>';
    14391445                        unset( $install_actions['activate_plugin'] );
    14401446                }
  • branches/3.5/wp-admin/update.php

    r22430 r24475  
    5858
    5959                $nonce = 'upgrade-plugin_' . $plugin;
    60                 $url = 'update.php?action=upgrade-plugin&plugin=' . $plugin;
     60                $url = 'update.php?action=upgrade-plugin&plugin=' . urlencode( $plugin );
    6161
    6262                $upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact('title', 'nonce', 'url', 'plugin') ) );
     
    7171                check_admin_referer('activate-plugin_' . $plugin);
    7272                if ( ! isset($_GET['failure']) && ! isset($_GET['success']) ) {
    73                         wp_redirect( admin_url('update.php?action=activate-plugin&failure=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce']) );
     73                        wp_redirect( admin_url('update.php?action=activate-plugin&failure=true&plugin=' . urlencode( $plugin ) . '&_wpnonce=' . $_GET['_wpnonce']) );
    7474                        activate_plugin( $plugin, '', ! empty( $_GET['networkwide'] ), true );
    75                         wp_redirect( admin_url('update.php?action=activate-plugin&success=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce']) );
     75                        wp_redirect( admin_url('update.php?action=activate-plugin&success=true&plugin=' . urlencode( $plugin ) . '&_wpnonce=' . $_GET['_wpnonce']) );
    7676                        die();
    7777                }
     
    108108                $title = sprintf( __('Installing Plugin: %s'), $api->name . ' ' . $api->version );
    109109                $nonce = 'install-plugin_' . $plugin;
    110                 $url = 'update.php?action=install-plugin&plugin=' . $plugin;
     110                $url = 'update.php?action=install-plugin&plugin=' . urlencode( $plugin );
    111111                if ( isset($_GET['from']) )
    112112                        $url .= '&from=' . urlencode(stripslashes($_GET['from']));
     
    133133                require_once(ABSPATH . 'wp-admin/admin-header.php');
    134134
    135                 $title = sprintf( __('Installing Plugin from uploaded file: %s'), basename( $file_upload->filename ) );
     135                $title = sprintf( __('Installing Plugin from uploaded file: %s'), esc_html( basename( $file_upload->filename ) ) );
    136136                $nonce = 'plugin-upload';
    137137                $url = add_query_arg(array('package' => $file_upload->id), 'update.php?action=upload-plugin');
     
    161161
    162162                $nonce = 'upgrade-theme_' . $theme;
    163                 $url = 'update.php?action=upgrade-theme&theme=' . $theme;
     163                $url = 'update.php?action=upgrade-theme&theme=' . urlencode( $theme );
    164164
    165165                $upgrader = new Theme_Upgrader( new Theme_Upgrader_Skin( compact('title', 'nonce', 'url', 'theme') ) );
     
    214214                $title = sprintf( __('Installing Theme: %s'), $api->name . ' ' . $api->version );
    215215                $nonce = 'install-theme_' . $theme;
    216                 $url = 'update.php?action=install-theme&theme=' . $theme;
     216                $url = 'update.php?action=install-theme&theme=' . urlencode( $theme );
    217217                $type = 'web'; //Install theme type, From Web or an Upload.
    218218
     
    239239                require_once(ABSPATH . 'wp-admin/admin-header.php');
    240240
    241                 $title = sprintf( __('Installing Theme from uploaded file: %s'), basename( $file_upload->filename ) );
     241                $title = sprintf( __('Installing Theme from uploaded file: %s'), esc_html( basename( $file_upload->filename ) ) );
    242242                $nonce = 'theme-upload';
    243243                $url = add_query_arg(array('package' => $file_upload->id), 'update.php?action=upload-theme');
Note: See TracChangeset for help on using the changeset viewer.