Make WordPress Core

Changeset 23567


Ignore:
Timestamp:
03/01/2013 05:14:09 PM (12 years ago)
Author:
ryan
Message:

Use wp_unslash() instead of stripslashes() and stripslashes_deep(). Use wp_slash() instead of add_magic_quotes().

Location:
trunk/wp-admin
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-comments.php

    r23563 r23567  
    2121
    2222    if ( 'delete_all' == $doaction && !empty( $_REQUEST['pagegen_timestamp'] ) ) {
    23         $comment_status = $_REQUEST['comment_status'];
    24         $delete_time = $_REQUEST['pagegen_timestamp'];
     23        $comment_status = wp_unslash( $_REQUEST['comment_status'] );
     24        $delete_time = wp_unslash ( $_REQUEST['pagegen_timestamp'] );
    2525        $comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_approved = %s AND %s > comment_date_gmt", $comment_status, $delete_time ) );
    2626        $doaction = 'delete';
  • trunk/wp-admin/includes/template.php

    r23554 r23567  
    13341334 */
    13351335function _admin_search_query() {
    1336     echo isset($_REQUEST['s']) ? esc_attr( stripslashes( $_REQUEST['s'] ) ) : '';
     1336    echo isset($_REQUEST['s']) ? esc_attr( wp_unslash( $_REQUEST['s'] ) ) : '';
    13371337}
    13381338
  • trunk/wp-admin/includes/theme-install.php

    r23554 r23567  
    5151 */
    5252function install_theme_search_form( $type_selector = true ) {
    53     $type = isset( $_REQUEST['type'] ) ? stripslashes( $_REQUEST['type'] ) : 'term';
    54     $term = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
     53    $type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term';
     54    $term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : '';
    5555    if ( ! $type_selector )
    5656        echo '<p class="install-help">' . __( 'Search for themes by keyword.' ) . '</p>';
     
    180180    global $tab, $themes_allowedtags, $wp_list_table;
    181181
    182     $theme = themes_api( 'theme_information', array( 'slug' => stripslashes( $_REQUEST['theme'] ) ) );
     182    $theme = themes_api( 'theme_information', array( 'slug' => wp_unslash( $_REQUEST['theme'] ) ) );
    183183
    184184    if ( is_wp_error( $theme ) )
  • trunk/wp-admin/includes/upgrade.php

    r23554 r23567  
    133133
    134134        if ( empty($first_post) )
    135             $first_post = stripslashes( __( 'Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' ) );
     135            $first_post = __( 'Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' );
    136136
    137137        $first_post = str_replace( "SITE_URL", esc_url( network_home_url() ), $first_post );
     
    637637    foreach ( $users as $user ) :
    638638        if ( !empty( $user->user_firstname ) )
    639             update_user_meta( $user->ID, 'first_name', $wpdb->escape($user->user_firstname) );
     639            update_user_meta( $user->ID, 'first_name', wp_slash($user->user_firstname) );
    640640        if ( !empty( $user->user_lastname ) )
    641             update_user_meta( $user->ID, 'last_name', $wpdb->escape($user->user_lastname) );
     641            update_user_meta( $user->ID, 'last_name', wp_slash($user->user_lastname) );
    642642        if ( !empty( $user->user_nickname ) )
    643             update_user_meta( $user->ID, 'nickname', $wpdb->escape($user->user_nickname) );
     643            update_user_meta( $user->ID, 'nickname', wp_slash($user->user_nickname) );
    644644        if ( !empty( $user->user_level ) )
    645645            update_user_meta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level );
    646646        if ( !empty( $user->user_icq ) )
    647             update_user_meta( $user->ID, 'icq', $wpdb->escape($user->user_icq) );
     647            update_user_meta( $user->ID, 'icq', wp_slash($user->user_icq) );
    648648        if ( !empty( $user->user_aim ) )
    649             update_user_meta( $user->ID, 'aim', $wpdb->escape($user->user_aim) );
     649            update_user_meta( $user->ID, 'aim', wp_slash($user->user_aim) );
    650650        if ( !empty( $user->user_msn ) )
    651             update_user_meta( $user->ID, 'msn', $wpdb->escape($user->user_msn) );
     651            update_user_meta( $user->ID, 'msn', wp_slash($user->user_msn) );
    652652        if ( !empty( $user->user_yim ) )
    653             update_user_meta( $user->ID, 'yim', $wpdb->escape($user->user_icq) );
     653            update_user_meta( $user->ID, 'yim', wp_slash($user->user_icq) );
    654654        if ( !empty( $user->user_description ) )
    655             update_user_meta( $user->ID, 'description', $wpdb->escape($user->user_description) );
     655            update_user_meta( $user->ID, 'description', wp_slash($user->user_description) );
    656656
    657657        if ( isset( $user->user_idmode ) ):
     
    855855            $cat_id = (int) $category->cat_id;
    856856            $term_id = 0;
    857             $name = $wpdb->escape($category->cat_name);
     857            $name = wp_slash($category->cat_name);
    858858            $slug = sanitize_title($name);
    859859            $term_group = 0;
  • trunk/wp-admin/includes/user.php

    r23554 r23567  
    3535        $user->ID = (int) $user_id;
    3636        $userdata = get_userdata( $user_id );
    37         $user->user_login = $wpdb->escape( $userdata->user_login );
     37        $user->user_login = wp_slash( $userdata->user_login );
    3838    } else {
    3939        $update = false;
  • trunk/wp-admin/install.php

    r23554 r23567  
    8585        $blog_public = isset( $_POST['blog_public'] );
    8686
    87     $weblog_title = isset( $_POST['weblog_title'] ) ? trim( stripslashes( $_POST['weblog_title'] ) ) : '';
    88     $user_name = isset($_POST['user_name']) ? trim( stripslashes( $_POST['user_name'] ) ) : 'admin';
    89     $admin_password = isset($_POST['admin_password']) ? trim( stripslashes( $_POST['admin_password'] ) ) : '';
    90     $admin_email  = isset( $_POST['admin_email']  ) ? trim( stripslashes( $_POST['admin_email'] ) ) : '';
     87    $weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : '';
     88    $user_name = isset($_POST['user_name']) ? trim( wp_unslash( $_POST['user_name'] ) ) : 'admin';
     89    $admin_password = isset($_POST['admin_password']) ? trim( wp_unslash( $_POST['admin_password'] ) ) : '';
     90    $admin_email  = isset( $_POST['admin_email']  ) ? trim( wp_unslash( $_POST['admin_email'] ) ) : '';
    9191
    9292    if ( ! is_null( $error ) ) {
     
    190190        display_header();
    191191        // Fill in the data we gathered
    192         $weblog_title = isset( $_POST['weblog_title'] ) ? trim( stripslashes( $_POST['weblog_title'] ) ) : '';
    193         $user_name = isset($_POST['user_name']) ? trim( stripslashes( $_POST['user_name'] ) ) : 'admin';
    194         $admin_password = isset($_POST['admin_password']) ? $_POST['admin_password'] : '';
    195         $admin_password_check = isset($_POST['admin_password2']) ? $_POST['admin_password2'] : '';
    196         $admin_email  = isset( $_POST['admin_email']  ) ?trim( stripslashes( $_POST['admin_email'] ) ) : '';
     192        $weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : '';
     193        $user_name = isset($_POST['user_name']) ? trim( wp_unslash( $_POST['user_name'] ) ) : 'admin';
     194        $admin_password = isset($_POST['admin_password']) ? wp_unslash( $_POST['admin_password'] ) : '';
     195        $admin_password_check = isset($_POST['admin_password2']) ? wp_unslash( $_POST['admin_password2'] ) : '';
     196        $admin_email  = isset( $_POST['admin_email']  ) ?trim( wp_unslash( $_POST['admin_email'] ) ) : '';
    197197        $public       = isset( $_POST['blog_public']  ) ? (int) $_POST['blog_public'] : 0;
    198198        // check e-mail address
  • trunk/wp-admin/link-manager.php

    r23554 r23567  
    3232    }
    3333} elseif ( ! empty( $_GET['_wp_http_referer'] ) ) {
    34      wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), stripslashes( $_SERVER['REQUEST_URI'] ) ) );
     34     wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
    3535     exit;
    3636}
     
    7373<h2><?php echo esc_html( $title ); ?> <a href="link-add.php" class="add-new-h2"><?php echo esc_html_x('Add New', 'link'); ?></a> <?php
    7474if ( !empty($_REQUEST['s']) )
    75     printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( stripslashes($_REQUEST['s']) ) ); ?>
     75    printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( wp_unslash($_REQUEST['s']) ) ); ?>
    7676</h2>
    7777
  • trunk/wp-admin/network.php

    r23554 r23567  
    521521    $subdomain_install = allow_subdomain_install() ? !empty( $_POST['subdomain_install'] ) : false;
    522522    if ( ! network_domain_check() ) {
    523         $result = populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), stripslashes( $_POST['sitename'] ), $base, $subdomain_install );
     523        $result = populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), wp_unslash( $_POST['sitename'] ), $base, $subdomain_install );
    524524        if ( is_wp_error( $result ) ) {
    525525            if ( 1 == count( $result->get_error_codes() ) && 'no_wildcard_dns' == $result->get_error_code() )
  • trunk/wp-admin/network/site-info.php

    r23554 r23567  
    6363
    6464    // update blogs table
    65     $blog_data = stripslashes_deep( $_POST['blog'] );
     65    $blog_data = wp_unslash( $_POST['blog'] );
    6666    $existing_details = get_blog_details( $id, false );
    6767    $blog_data_checkboxes = array( 'public', 'archived', 'spam', 'mature', 'deleted' );
  • trunk/wp-admin/network/site-new.php

    r23554 r23567  
    8989
    9090Address: %2$s
    91 Name: %3$s' ), $current_user->user_login , get_site_url( $id ), stripslashes( $title ) );
     91Name: %3$s' ), $current_user->user_login , get_site_url( $id ), wp_unslash( $title ) );
    9292        wp_mail( get_site_option('admin_email'), sprintf( __( '[%s] New Site Created' ), $current_site->site_name ), $content_mail, 'From: "Site Admin" <' . get_site_option( 'admin_email' ) . '>' );
    9393        wpmu_welcome_notification( $id, $user_id, $password, $title, array( 'public' => 1 ) );
  • trunk/wp-admin/network/site-settings.php

    r23554 r23567  
    5454    $skip_options = array( 'allowedthemes' ); // Don't update these options since they are handled elsewhere in the form.
    5555    foreach ( (array) $_POST['option'] as $key => $val ) {
     56        $key = wp_unslash( $key );
     57        $val = wp_unslash( $val );
    5658        if ( $key === 0 || is_array( $val ) || in_array($key, $skip_options) )
    5759            continue; // Avoids "0 is a protected WP option and may not be modified" error when edit blog options
    5860        if ( $c == $count )
    59             update_option( $key, stripslashes( $val ) );
     61            update_option( $key, $val );
    6062        else
    61             update_option( $key, stripslashes( $val ), false ); // no need to refresh blog details yet
     63            update_option( $key, $val, false ); // no need to refresh blog details yet
    6264        $c++;
    6365    }
  • trunk/wp-admin/network/sites.php

    r23554 r23567  
    8080                    <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" />
    8181                    <?php wp_nonce_field( $_GET['action2'], '_wpnonce', false ); ?>
    82                     <p><?php echo esc_html( stripslashes( $_GET['msg'] ) ); ?></p>
     82                    <p><?php echo esc_html( wp_unslash( $_GET['msg'] ) ); ?></p>
    8383                    <?php submit_button( __('Confirm'), 'button' ); ?>
    8484                </form>
  • trunk/wp-admin/options-head.php

    r23554 r23567  
    33 * WordPress Options Header.
    44 *
    5  * Resets variables: 'action', 'standalone', and 'option_group_id'. Displays
    6  * updated message, if updated variable is part of the URL query.
     5 * Displays updated message, if updated variable is part of the URL query.
    76 *
    87 * @package WordPress
  • trunk/wp-admin/options.php

    r23554 r23567  
    121121        if ( is_multisite() && ! is_super_admin() )
    122122            wp_die( __( 'You do not have sufficient permissions to modify unregistered settings for this site.' ) );
    123         $options = explode( ',', stripslashes( $_POST[ 'page_options' ] ) );
     123        $options = explode( ',', wp_unslash( $_POST[ 'page_options' ] ) );
    124124    } else {
    125125        $options = $whitelist_options[ $option_page ];
     
    128128    // Handle custom date/time formats
    129129    if ( 'general' == $option_page ) {
    130         if ( !empty($_POST['date_format']) && isset($_POST['date_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['date_format'] ) )
     130        if ( !empty($_POST['date_format']) && isset($_POST['date_format_custom']) && '\c\u\s\t\o\m' == wp_unslash( $_POST['date_format'] ) )
    131131            $_POST['date_format'] = $_POST['date_format_custom'];
    132         if ( !empty($_POST['time_format']) && isset($_POST['time_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['time_format'] ) )
     132        if ( !empty($_POST['time_format']) && isset($_POST['time_format_custom']) && '\c\u\s\t\o\m' == wp_unslash( $_POST['time_format'] ) )
    133133            $_POST['time_format'] = $_POST['time_format_custom'];
    134134        // Map UTC+- timezones to gmt_offsets and set timezone_string to empty.
     
    151151                if ( ! is_array( $value ) )
    152152                    $value = trim( $value );
    153                 $value = stripslashes_deep( $value );
     153                $value = wp_unslash( $value );
    154154            }
    155155            update_option( $option, $value );
  • trunk/wp-admin/plugin-editor.php

    r23554 r23567  
    2929
    3030if ( isset($_REQUEST['file']) )
    31     $plugin = stripslashes($_REQUEST['file']);
     31    $plugin = wp_unslash($_REQUEST['file']);
    3232
    3333if ( empty($plugin) ) {
     
    4040if ( empty($file) )
    4141    $file = $plugin_files[0];
    42 else
    43     $file = stripslashes($file);
    4442
    4543$file = validate_file_to_edit($file, $plugin_files);
     
    5351    check_admin_referer('edit-plugin_' . $file);
    5452
    55     $newcontent = stripslashes($_POST['newcontent']);
     53    $newcontent = wp_unslash( $_POST['newcontent'] );
    5654    if ( is_writeable($real_file) ) {
    5755        $f = fopen($real_file, 'w+');
  • trunk/wp-admin/press-this.php

    r23554 r23567  
    9292
    9393// Set Variables
    94 $title = isset( $_GET['t'] ) ? trim( strip_tags( html_entity_decode( stripslashes( $_GET['t'] ) , ENT_QUOTES) ) ) : '';
     94$title = isset( $_GET['t'] ) ? trim( strip_tags( html_entity_decode( wp_unslash( $_GET['t'] ) , ENT_QUOTES) ) ) : '';
    9595
    9696$selection = '';
    9797if ( !empty($_GET['s']) ) {
    98     $selection = str_replace('&apos;', "'", stripslashes($_GET['s']));
     98    $selection = str_replace('&apos;', "'", wp_unslash($_GET['s']));
    9999    $selection = trim( htmlspecialchars( html_entity_decode($selection, ENT_QUOTES) ) );
    100100}
  • trunk/wp-admin/setup-config.php

    r23566 r23567  
    165165    case 2:
    166166    foreach ( array( 'dbname', 'uname', 'pwd', 'dbhost', 'prefix' ) as $key )
    167         $$key = trim( stripslashes( $_POST[ $key ] ) );
     167        $$key = trim( wp_unslash( $_POST[ $key ] ) );
    168168
    169169    $tryagain_link = '</p><p class="step"><a href="setup-config.php?step=1" onclick="javascript:history.go(-1);return false;" class="button button-large">' . __( 'Try again' ) . '</a>';
  • trunk/wp-admin/theme-editor.php

    r23554 r23567  
    6969    $file = $allowed_files['style.css'];
    7070} else {
    71     $relative_file = stripslashes( $file );
     71    $relative_file = wp_unslash( $file );
    7272    $file = $theme->get_stylesheet_directory() . '/' . $relative_file;
    7373}
     
    7979case 'update':
    8080    check_admin_referer( 'edit-theme_' . $file . $stylesheet );
    81     $newcontent = stripslashes( $_POST['newcontent'] );
     81    $newcontent = wp_unslash( $_POST['newcontent'] );
    8282    $location = 'theme-editor.php?file=' . urlencode( $relative_file ) . '&theme=' . urlencode( $stylesheet ) . '&scrollto=' . $scrollto;
    8383    if ( is_writeable( $file ) ) {
  • trunk/wp-admin/upgrade.php

    r23554 r23567  
    7878switch ( $step ) :
    7979    case 0:
    80         $goback = stripslashes( wp_get_referer() );
     80        $goback = wp_unslash( wp_get_referer() );
    8181        $goback = esc_url_raw( $goback );
    8282        $goback = urlencode( $goback );
     
    9191        wp_upgrade();
    9292
    93             $backto = !empty($_GET['backto']) ? stripslashes( urldecode( $_GET['backto'] ) ) : __get_option( 'home' ) . '/';
     93            $backto = !empty($_GET['backto']) ? wp_unslash( urldecode( $_GET['backto'] ) ) : __get_option( 'home' ) . '/';
    9494            $backto = esc_url( $backto );
    9595            $backto = wp_validate_redirect($backto, __get_option( 'home' ) . '/');
  • trunk/wp-admin/upload.php

    r23554 r23567  
    133133    exit;
    134134} elseif ( ! empty( $_GET['_wp_http_referer'] ) ) {
    135      wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), stripslashes( $_SERVER['REQUEST_URI'] ) ) );
     135     wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
    136136     exit;
    137137}
Note: See TracChangeset for help on using the changeset viewer.