Make WordPress Core

Ticket #18039: 18039.diff

File 18039.diff, 3.9 KB (added by boonebgorges, 15 years ago)
  • wp-includes/formatting.php

     
    23502350        return apply_filters( 'attribute_escape', $safe_text, $text );
    23512351}
    23522352
     2353
    23532354/**
     2355 * Escape an email address
     2356 *
     2357 * This works just like esc_html(), except that single quotes are permitted
     2358 *
     2359 * @since 3.3
     2360 *
     2361 * @param string $email The email address to be escaped
     2362 * @return string The escaped email
     2363 */
     2364function esc_email( $email ) {
     2365        $safe_email = wp_check_invalid_utf8( $email );
     2366        $safe_email = _wp_specialchars( $safe_email, ENT_COMPAT );
     2367        return apply_filters( 'esc_email', $safe_email, $email );
     2368}
     2369
     2370/**
    23542371 * Escaping for textarea values.
    23552372 *
    23562373 * @since 3.1
  • wp-admin/includes/user.php

     
    8989        }
    9090
    9191        if ( isset( $_POST['email'] ))
    92                 $user->user_email = sanitize_text_field( $_POST['email'] );
     92                $user->user_email = sanitize_text_field( stripslashes( $_POST['email'] ) );
    9393        if ( isset( $_POST['url'] ) ) {
    9494                if ( empty ( $_POST['url'] ) || $_POST['url'] == 'http://' ) {
    9595                        $user->user_url = '';
  • wp-admin/user-new.php

     
    3939        check_admin_referer( 'add-user', '_wpnonce_add-user' );
    4040
    4141        $user_details = null;
    42         if ( false !== strpos($_REQUEST[ 'email' ], '@') ) {
    43                 $user_details = get_user_by('email', $_REQUEST[ 'email' ]);
     42        $email = stripslashes( $_REQUEST['email'] );
     43        if ( false !== strpos( $email, '@' ) ) {
     44                $user_details = get_user_by( 'email', $email );
    4445        } else {
    4546                if ( is_super_admin() ) {
    46                         $user_details = get_user_by('login', $_REQUEST[ 'email' ]);
     47                        $user_details = get_user_by( 'login', $email );
    4748                } else {
    4849                        wp_redirect( add_query_arg( array('update' => 'enter_email'), 'user-new.php' ) );
    4950                        die();
     
    5960                wp_die(__('Cheatin’ uh?'));
    6061
    6162        // Adding an existing user to this blog
    62         $new_user_email = esc_html(trim($_REQUEST['email']));
     63        $new_user_email = esc_email( trim( $email ) );
    6364        $redirect = 'user-new.php';
    6465        $username = $user_details->user_login;
    6566        $user_id = $user_details->ID;
     
    102103                }
    103104        } else {
    104105                // Adding a new user to this blog
    105                 $user_details = wpmu_validate_user_signup( $_REQUEST[ 'user_login' ], $_REQUEST[ 'email' ] );
     106                $email = stripslashes( $_REQUEST[ 'email' ] );
     107                $user_details = wpmu_validate_user_signup( $_REQUEST[ 'user_login' ], $email );
    106108                unset( $user_details[ 'errors' ]->errors[ 'user_email_used' ] );
    107109                if ( is_wp_error( $user_details[ 'errors' ] ) && !empty( $user_details[ 'errors' ]->errors ) ) {
    108110                        $add_user_errors = $user_details[ 'errors' ];
     
    111113                        if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) {
    112114                                add_filter( 'wpmu_signup_user_notification', '__return_false' ); // Disable confirmation email
    113115                        }
    114                         wpmu_signup_user( $new_user_login, $_REQUEST[ 'email' ], array( 'add_to_blog' => $wpdb->blogid, 'new_role' => $_REQUEST[ 'role' ] ) );
     116                        wpmu_signup_user( $new_user_login, $email, array( 'add_to_blog' => $wpdb->blogid, 'new_role' => $_REQUEST[ 'role' ] ) );
    115117                        if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) {
    116                                 $key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $new_user_login, $_REQUEST[ 'email' ] ) );
     118                                $key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $new_user_login, $email ) );
    117119                                wpmu_activate_signup( $key );
    118120                                $redirect = add_query_arg( array('update' => 'addnoconfirmation'), 'user-new.php' );
    119121                        } else {