diff options
author | Andrew Nacin <nacin@git.wordpress.org> | 2013-06-21 05:55:56 +0000 |
---|---|---|
committer | Andrew Nacin <nacin@git.wordpress.org> | 2013-06-21 05:55:56 +0000 |
commit | 579b13a58a2262ea39f195740f406c6a09b47240 (patch) | |
tree | 9dc8a1c00f05136259244c4ffcdaba708a6d2251 | |
parent | 0c96244c7078795417a462a6297bb638bb3f4dcc (diff) | |
download | wordpress-579b13a58a2262ea39f195740f406c6a09b47240.tar.gz wordpress-579b13a58a2262ea39f195740f406c6a09b47240.zip |
More robust escaping in the plugin/theme upgrader.
Merges [24474] to the 3.5 branch.
git-svn-id: https://develop.svn.wordpress.org/branches/3.5@24475 602fd350-edb4-49c9-b593-d223f7449a82
-rw-r--r-- | wp-admin/includes/class-wp-upgrader.php | 28 | ||||
-rw-r--r-- | wp-admin/update.php | 16 |
2 files changed, 25 insertions, 19 deletions
diff --git a/wp-admin/includes/class-wp-upgrader.php b/wp-admin/includes/class-wp-upgrader.php index ef8fb5f884..63155927df 100644 --- a/wp-admin/includes/class-wp-upgrader.php +++ b/wp-admin/includes/class-wp-upgrader.php @@ -98,7 +98,7 @@ class WP_Upgrader { break; default: if ( ! $wp_filesystem->find_folder($dir) ) - return new WP_Error('fs_no_folder', sprintf($this->strings['fs_no_folder'], $dir)); + return new WP_Error( 'fs_no_folder', sprintf( $this->strings['fs_no_folder'], esc_html( basename( $dir ) ) ) ); break; } } @@ -1133,7 +1133,7 @@ class WP_Upgrader_Skin { } elseif ( is_wp_error($errors) && $errors->get_error_code() ) { foreach ( $errors->get_error_messages() as $message ) { if ( $errors->get_error_data() ) - $this->feedback($message . ' ' . $errors->get_error_data() ); + $this->feedback($message . ' ' . esc_html( $errors->get_error_data() ) ); else $this->feedback($message); } @@ -1147,8 +1147,11 @@ class WP_Upgrader_Skin { if ( strpos($string, '%') !== false ) { $args = func_get_args(); $args = array_splice($args, 1); - if ( !empty($args) ) + if ( $args ) { + $args = array_map( 'strip_tags', $args ); + $args = array_map( 'esc_html', $args ); $string = vsprintf($string, $args); + } } if ( empty($string) ) return; @@ -1188,11 +1191,11 @@ class Plugin_Upgrader_Skin extends WP_Upgrader_Skin { function after() { $this->plugin = $this->upgrader->plugin_info(); if ( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){ - 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>'; + 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>'; } $update_actions = array( - 'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $this->plugin, 'activate-plugin_' . $this->plugin) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>', + 'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>', 'plugins_page' => '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Go to plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>' ); if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugins' ) ) @@ -1244,8 +1247,11 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin { if ( strpos($string, '%') !== false ) { $args = func_get_args(); $args = array_splice($args, 1); - if ( !empty($args) ) + if ( $args ) { + $args = array_map( 'strip_tags', $args ); + $args = array_map( 'esc_html', $args ); $string = vsprintf($string, $args); + } } if ( empty($string) ) return; @@ -1269,7 +1275,7 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin { if ( is_wp_error($error) ) { foreach ( $error->get_error_messages() as $emessage ) { if ( $error->get_error_data() ) - $messages[] = $emessage . ' ' . $error->get_error_data(); + $messages[] = $emessage . ' ' . esc_html( $error->get_error_data() ); else $messages[] = $emessage; } @@ -1430,12 +1436,12 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin { $from = isset($_GET['from']) ? stripslashes($_GET['from']) : 'plugins'; if ( 'import' == $from ) - $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&from=import&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin & Run Importer') . '</a>'; + $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&from=import&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin & Run Importer') . '</a>'; else - $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>'; + $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>'; if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) { - $install_actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&networkwide=1&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin for all sites in this network') . '" target="_parent">' . __('Network Activate') . '</a>'; + $install_actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&networkwide=1&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>'; unset( $install_actions['activate_plugin'] ); } @@ -1670,4 +1676,4 @@ class File_Upload_Upgrader { return true; } -}
\ No newline at end of file +} diff --git a/wp-admin/update.php b/wp-admin/update.php index 687142e218..caed6e794d 100644 --- a/wp-admin/update.php +++ b/wp-admin/update.php @@ -57,7 +57,7 @@ if ( isset($_GET['action']) ) { require_once(ABSPATH . 'wp-admin/admin-header.php'); $nonce = 'upgrade-plugin_' . $plugin; - $url = 'update.php?action=upgrade-plugin&plugin=' . $plugin; + $url = 'update.php?action=upgrade-plugin&plugin=' . urlencode( $plugin ); $upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact('title', 'nonce', 'url', 'plugin') ) ); $upgrader->upgrade($plugin); @@ -70,9 +70,9 @@ if ( isset($_GET['action']) ) { check_admin_referer('activate-plugin_' . $plugin); if ( ! isset($_GET['failure']) && ! isset($_GET['success']) ) { - wp_redirect( admin_url('update.php?action=activate-plugin&failure=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce']) ); + wp_redirect( admin_url('update.php?action=activate-plugin&failure=true&plugin=' . urlencode( $plugin ) . '&_wpnonce=' . $_GET['_wpnonce']) ); activate_plugin( $plugin, '', ! empty( $_GET['networkwide'] ), true ); - wp_redirect( admin_url('update.php?action=activate-plugin&success=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce']) ); + wp_redirect( admin_url('update.php?action=activate-plugin&success=true&plugin=' . urlencode( $plugin ) . '&_wpnonce=' . $_GET['_wpnonce']) ); die(); } iframe_header( __('Plugin Reactivation'), true ); @@ -107,7 +107,7 @@ if ( isset($_GET['action']) ) { $title = sprintf( __('Installing Plugin: %s'), $api->name . ' ' . $api->version ); $nonce = 'install-plugin_' . $plugin; - $url = 'update.php?action=install-plugin&plugin=' . $plugin; + $url = 'update.php?action=install-plugin&plugin=' . urlencode( $plugin ); if ( isset($_GET['from']) ) $url .= '&from=' . urlencode(stripslashes($_GET['from'])); @@ -132,7 +132,7 @@ if ( isset($_GET['action']) ) { $submenu_file = 'plugin-install.php'; require_once(ABSPATH . 'wp-admin/admin-header.php'); - $title = sprintf( __('Installing Plugin from uploaded file: %s'), basename( $file_upload->filename ) ); + $title = sprintf( __('Installing Plugin from uploaded file: %s'), esc_html( basename( $file_upload->filename ) ) ); $nonce = 'plugin-upload'; $url = add_query_arg(array('package' => $file_upload->id), 'update.php?action=upload-plugin'); $type = 'upload'; //Install plugin type, From Web or an Upload. @@ -160,7 +160,7 @@ if ( isset($_GET['action']) ) { require_once(ABSPATH . 'wp-admin/admin-header.php'); $nonce = 'upgrade-theme_' . $theme; - $url = 'update.php?action=upgrade-theme&theme=' . $theme; + $url = 'update.php?action=upgrade-theme&theme=' . urlencode( $theme ); $upgrader = new Theme_Upgrader( new Theme_Upgrader_Skin( compact('title', 'nonce', 'url', 'theme') ) ); $upgrader->upgrade($theme); @@ -213,7 +213,7 @@ if ( isset($_GET['action']) ) { $title = sprintf( __('Installing Theme: %s'), $api->name . ' ' . $api->version ); $nonce = 'install-theme_' . $theme; - $url = 'update.php?action=install-theme&theme=' . $theme; + $url = 'update.php?action=install-theme&theme=' . urlencode( $theme ); $type = 'web'; //Install theme type, From Web or an Upload. $upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) ); @@ -238,7 +238,7 @@ if ( isset($_GET['action']) ) { require_once(ABSPATH . 'wp-admin/admin-header.php'); - $title = sprintf( __('Installing Theme from uploaded file: %s'), basename( $file_upload->filename ) ); + $title = sprintf( __('Installing Theme from uploaded file: %s'), esc_html( basename( $file_upload->filename ) ) ); $nonce = 'theme-upload'; $url = add_query_arg(array('package' => $file_upload->id), 'update.php?action=upload-theme'); $type = 'upload'; //Install plugin type, From Web or an Upload. |