Permalink
Browse files

Always URL-encode a stylesheet directory value before using it in a U…

…RL. These situations are saved by wp_nonce_url(), but we should not depend on that. see #21749, for trunk only.

git-svn-id: http://core.svn.wordpress.org/trunk@21755 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information...
1 parent d476c22 commit fb36abe6b7fee49440f009d90cb35f0e50eabdf0 @nacin nacin committed Sep 4, 2012
@@ -277,27 +277,28 @@ function single_row( $key, $theme ) {
'delete' => ''
);
- $theme_key = $theme->get_stylesheet();
+ $stylesheet = $theme->get_stylesheet();
+ $theme_key = urlencode( $stylesheet );
if ( ! $allowed ) {
if ( ! $theme->errors() )
- $actions['enable'] = '<a href="' . esc_url( wp_nonce_url($url . 'action=enable&amp;theme=' . $theme_key . '&amp;paged=' . $page . '&amp;s=' . $s, 'enable-theme_' . $theme_key) ) . '" title="' . esc_attr__('Enable this theme') . '" class="edit">' . ( $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) ) . '</a>';
+ $actions['enable'] = '<a href="' . esc_url( wp_nonce_url($url . 'action=enable&amp;theme=' . $theme_key . '&amp;paged=' . $page . '&amp;s=' . $s, 'enable-theme_' . $stylesheet ) ) . '" title="' . esc_attr__('Enable this theme') . '" class="edit">' . ( $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) ) . '</a>';
} else {
- $actions['disable'] = '<a href="' . esc_url( wp_nonce_url($url . 'action=disable&amp;theme=' . $theme_key . '&amp;paged=' . $page . '&amp;s=' . $s, 'disable-theme_' . $theme_key) ) . '" title="' . esc_attr__('Disable this theme') . '">' . ( $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) ) . '</a>';
+ $actions['disable'] = '<a href="' . esc_url( wp_nonce_url($url . 'action=disable&amp;theme=' . $theme_key . '&amp;paged=' . $page . '&amp;s=' . $s, 'disable-theme_' . $stylesheet ) ) . '" title="' . esc_attr__('Disable this theme') . '">' . ( $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) ) . '</a>';
}
if ( current_user_can('edit_themes') )
- $actions['edit'] = '<a href="' . esc_url('theme-editor.php?theme=' . urlencode( $theme_key ) ) . '" title="' . esc_attr__('Open this theme in the Theme Editor') . '" class="edit">' . __('Edit') . '</a>';
+ $actions['edit'] = '<a href="' . esc_url('theme-editor.php?theme=' . $theme_key ) . '" title="' . esc_attr__('Open this theme in the Theme Editor') . '" class="edit">' . __('Edit') . '</a>';
- if ( ! $allowed && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $theme_key != get_option( 'stylesheet' ) && $theme_key != get_option( 'template' ) )
+ if ( ! $allowed && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $stylesheet != get_option( 'stylesheet' ) && $stylesheet != get_option( 'template' ) )
$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=delete-selected&amp;checked[]=' . $theme_key . '&amp;theme_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-themes' ) ) . '" title="' . esc_attr__( 'Delete this theme' ) . '" class="delete">' . __( 'Delete' ) . '</a>';
- $actions = apply_filters( 'theme_action_links', array_filter( $actions ), $theme_key, $theme, $context );
- $actions = apply_filters( "theme_action_links_$theme_key", $actions, $theme_key, $theme, $context );
+ $actions = apply_filters( 'theme_action_links', array_filter( $actions ), $stylesheet, $theme, $context );
+ $actions = apply_filters( "theme_action_links_$stylesheet", $actions, $stylesheet, $theme, $context );
$class = ! $allowed ? 'inactive' : 'active';
$checkbox_id = "checkbox_" . md5( $theme->get('Name') );
- $checkbox = "<input type='checkbox' name='checked[]' value='" . esc_attr( $theme_key ) . "' id='" . $checkbox_id . "' /><label class='screen-reader-text' for='" . $checkbox_id . "' >" . __('Select') . " " . $theme->display('Name') . "</label>";
+ $checkbox = "<input type='checkbox' name='checked[]' value='" . esc_attr( $stylesheet ) . "' id='" . $checkbox_id . "' /><label class='screen-reader-text' for='" . $checkbox_id . "' >" . __('Select') . " " . $theme->display('Name') . "</label>";
$id = sanitize_html_class( $theme->get_stylesheet() );
@@ -341,24 +342,24 @@ function single_row( $key, $theme ) {
if ( $theme->get('ThemeURI') )
$theme_meta[] = '<a href="' . $theme->display('ThemeURI') . '" title="' . esc_attr__( 'Visit theme homepage' ) . '">' . __( 'Visit Theme Site' ) . '</a>';
- $theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $theme_key, $theme, $status );
+ $theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $stylesheet, $theme, $status );
echo implode( ' | ', $theme_meta );
echo "</div></td>";
break;
default:
echo "<td class='$column_name column-$column_name'$style>";
- do_action( 'manage_themes_custom_column', $column_name, $theme_key, $theme );
+ do_action( 'manage_themes_custom_column', $column_name, $stylesheet, $theme );
echo "</td>";
}
}
echo "</tr>";
if ( $this->is_site_themes )
- remove_action( "after_theme_row_$theme_key", 'wp_theme_update_row' );
- do_action( 'after_theme_row', $theme_key, $theme, $status );
- do_action( "after_theme_row_$theme_key", $theme_key, $theme, $status );
+ remove_action( "after_theme_row_$stylesheet", 'wp_theme_update_row' );
+ do_action( 'after_theme_row', $stylesheet, $theme, $status );
+ do_action( "after_theme_row_$stylesheet", $stylesheet, $theme, $status );
}
}
@@ -143,7 +143,7 @@ function display_rows() {
. __( 'Live Preview' ) . '</a>';
if ( ! is_multisite() && current_user_can( 'delete_themes' ) )
- $actions['delete'] = '<a class="submitdelete deletion" href="' . wp_nonce_url( "themes.php?action=delete&amp;stylesheet=$stylesheet", 'delete-theme_' . $stylesheet )
+ $actions['delete'] = '<a class="submitdelete deletion" href="' . wp_nonce_url( 'themes.php?action=delete&amp;stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet )
. '" onclick="' . "return confirm( '" . esc_js( sprintf( __( "You are about to delete this theme '%s'\n 'Cancel' to stop, 'OK' to delete." ), $title ) )
. "' );" . '">' . __( 'Delete' ) . '</a>';
@@ -1502,7 +1502,7 @@ function after() {
'preview' => 1,
'template' => urlencode( $template ),
'stylesheet' => urlencode( $stylesheet ),
- ), trailingslashit( get_home_url() ) );
+ ), trailingslashit( home_url() ) );
$activate_link = add_query_arg( array(
'action' => 'activate',
@@ -1517,7 +1517,7 @@ function after() {
$install_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate &#8220;%s&#8221;'), $name ) ) . '">' . __('Activate') . '</a>';
if ( is_network_admin() && current_user_can( 'manage_network_themes' ) )
- $install_actions['network_enable'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=enable&amp;theme=' . $stylesheet, 'enable-theme_' . $stylesheet ) ) . '" title="' . esc_attr__( 'Enable this theme for all sites in this network' ) . '" target="_parent">' . __( 'Network Enable' ) . '</a>';
+ $install_actions['network_enable'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=enable&amp;theme=' . urlencode( $stylesheet ), 'enable-theme_' . $stylesheet ) ) . '" title="' . esc_attr__( 'Enable this theme for all sites in this network' ) . '" target="_parent">' . __( 'Network Enable' ) . '</a>';
if ( $this->type == 'web' )
$install_actions['themes_page'] = '<a href="' . self_admin_url('theme-install.php') . '" title="' . esc_attr__('Return to Theme Installer') . '" target="_parent">' . __('Return to Theme Installer') . '</a>';
@@ -1566,7 +1566,7 @@ function after() {
'preview' => 1,
'template' => urlencode( $template ),
'stylesheet' => urlencode( $stylesheet ),
- ), trailingslashit( get_home_url() ) );
+ ), trailingslashit( home_url() ) );
$activate_link = add_query_arg( array(
'action' => 'activate',
@@ -23,7 +23,7 @@ function delete_theme($stylesheet, $redirect = '') {
ob_start();
if ( empty( $redirect ) )
- $redirect = wp_nonce_url('themes.php?action=delete&stylesheet=' . $stylesheet, 'delete-theme_' . $stylesheet);
+ $redirect = wp_nonce_url('themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet);
if ( false === ($credentials = request_filesystem_credentials($redirect)) ) {
$data = ob_get_contents();
ob_end_clean();
@@ -46,7 +46,7 @@
wp_reset_vars( array( 'action', 'error', 'file', 'theme' ) );
if ( $theme )
- $stylesheet = urldecode( $theme );
+ $stylesheet = $theme;
else
$stylesheet = get_stylesheet();
@@ -68,7 +68,7 @@
$relative_file = 'style.css';
$file = $allowed_files['style.css'];
} else {
- $relative_file = urldecode( stripslashes( $file ) );
+ $relative_file = stripslashes( $file );
$file = $theme->get_stylesheet_directory() . '/' . $relative_file;
}

0 comments on commit fb36abe

Please sign in to comment.