Make WordPress Core


Ignore:
Timestamp:
09/04/2012 10:35:12 PM (13 years ago)
Author:
nacin
Message:

Always URL-encode a stylesheet directory value before using it in a URL. These situations are saved by wp_nonce_url(), but we should not depend on that. see #21749, for trunk only.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-ms-themes-list-table.php

    r21752 r21755  
    278278        );
    279279
    280         $theme_key = $theme->get_stylesheet();
     280        $stylesheet = $theme->get_stylesheet();
     281        $theme_key = urlencode( $stylesheet );
    281282
    282283        if ( ! $allowed ) {
    283284            if ( ! $theme->errors() )
    284                 $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>';
     285                $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>';
    285286        } else {
    286             $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>';
     287            $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>';
    287288        }
    288289
    289290        if ( current_user_can('edit_themes') )
    290             $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>';
    291 
    292         if ( ! $allowed && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $theme_key != get_option( 'stylesheet' ) && $theme_key != get_option( 'template' ) )
     291            $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>';
     292
     293        if ( ! $allowed && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $stylesheet != get_option( 'stylesheet' ) && $stylesheet != get_option( 'template' ) )
    293294            $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>';
    294295
    295         $actions = apply_filters( 'theme_action_links', array_filter( $actions ), $theme_key, $theme, $context );
    296         $actions = apply_filters( "theme_action_links_$theme_key", $actions, $theme_key, $theme, $context );
     296        $actions = apply_filters( 'theme_action_links', array_filter( $actions ), $stylesheet, $theme, $context );
     297        $actions = apply_filters( "theme_action_links_$stylesheet", $actions, $stylesheet, $theme, $context );
    297298
    298299        $class = ! $allowed ? 'inactive' : 'active';
    299300        $checkbox_id = "checkbox_" . md5( $theme->get('Name') );
    300         $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>";
     301        $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>";
    301302
    302303        $id = sanitize_html_class( $theme->get_stylesheet() );
     
    342343                        $theme_meta[] = '<a href="' . $theme->display('ThemeURI') . '" title="' . esc_attr__( 'Visit theme homepage' ) . '">' . __( 'Visit Theme Site' ) . '</a>';
    343344
    344                     $theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $theme_key, $theme, $status );
     345                    $theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $stylesheet, $theme, $status );
    345346                    echo implode( ' | ', $theme_meta );
    346347
     
    350351                default:
    351352                    echo "<td class='$column_name column-$column_name'$style>";
    352                     do_action( 'manage_themes_custom_column', $column_name, $theme_key, $theme );
     353                    do_action( 'manage_themes_custom_column', $column_name, $stylesheet, $theme );
    353354                    echo "</td>";
    354355            }
     
    358359
    359360        if ( $this->is_site_themes )
    360             remove_action( "after_theme_row_$theme_key", 'wp_theme_update_row' );
    361         do_action( 'after_theme_row', $theme_key, $theme, $status );
    362         do_action( "after_theme_row_$theme_key", $theme_key, $theme, $status );
     361            remove_action( "after_theme_row_$stylesheet", 'wp_theme_update_row' );
     362        do_action( 'after_theme_row', $stylesheet, $theme, $status );
     363        do_action( "after_theme_row_$stylesheet", $stylesheet, $theme, $status );
    363364    }
    364365}
Note: See TracChangeset for help on using the changeset viewer.