Make WordPress Core

Ticket #44901: 44901.5.diff

File 44901.5.diff, 3.8 KB (added by garrett-eclipse, 7 years ago)

Updated patch to place periods on 'Invalid key', and switch error to 'Missing confirm key.'

  • src/wp-includes/user.php

     
    23132313        $key = preg_replace( '/[^a-z0-9]/i', '', $key );
    23142314
    23152315        if ( empty( $key ) || ! is_string( $key ) ) {
    2316                 return new WP_Error( 'invalid_key', __( 'Invalid key' ) );
     2316                return new WP_Error( 'invalid_key', __( 'Invalid key.' ) );
    23172317        }
    23182318
    23192319        if ( empty( $login ) || ! is_string( $login ) ) {
    2320                 return new WP_Error( 'invalid_key', __( 'Invalid key' ) );
     2320                return new WP_Error( 'invalid_key', __( 'Invalid key.' ) );
    23212321        }
    23222322
    23232323        $row = $wpdb->get_row( $wpdb->prepare( "SELECT ID, user_activation_key FROM $wpdb->users WHERE user_login = %s", $login ) );
    23242324        if ( ! $row ) {
    2325                 return new WP_Error( 'invalid_key', __( 'Invalid key' ) );
     2325                return new WP_Error( 'invalid_key', __( 'Invalid key.' ) );
    23262326        }
    23272327
    23282328        if ( empty( $wp_hasher ) ) {
     
    23482348        }
    23492349
    23502350        if ( ! $pass_key ) {
    2351                 return new WP_Error( 'invalid_key', __( 'Invalid key' ) );
     2351                return new WP_Error( 'invalid_key', __( 'Invalid key.' ) );
    23522352        }
    23532353
    23542354        $hash_is_correct = $wp_hasher->CheckPassword( $key, $pass_key );
     
    23572357                return get_userdata( $row->ID );
    23582358        } elseif ( $hash_is_correct && $expiration_time ) {
    23592359                // Key has an expiration time that's passed
    2360                 return new WP_Error( 'expired_key', __( 'Invalid key' ) );
     2360                return new WP_Error( 'expired_key', __( 'Invalid key.' ) );
    23612361        }
    23622362
    23632363        if ( hash_equals( $row->user_activation_key, $key ) || ( $hash_is_correct && ! $expiration_time ) ) {
    2364                 $return  = new WP_Error( 'expired_key', __( 'Invalid key' ) );
     2364                $return  = new WP_Error( 'expired_key', __( 'Invalid key.' ) );
    23652365                $user_id = $row->ID;
    23662366
    23672367                /**
     
    23782378                return apply_filters( 'password_reset_key_expired', $return, $user_id );
    23792379        }
    23802380
    2381         return new WP_Error( 'invalid_key', __( 'Invalid key' ) );
     2381        return new WP_Error( 'invalid_key', __( 'Invalid key.' ) );
    23822382}
    23832383
    23842384/**
     
    35743574        }
    35753575
    35763576        if ( empty( $key ) ) {
    3577                 return new WP_Error( 'invalid_key', __( 'Invalid key' ) );
     3577                return new WP_Error( 'missing_key', __( 'Missing confirm key.' ) );
    35783578        }
    35793579
    35803580        if ( empty( $wp_hasher ) ) {
     
    35863586        $saved_key        = $request->confirm_key;
    35873587
    35883588        if ( ! $saved_key ) {
    3589                 return new WP_Error( 'invalid_key', __( 'Invalid key' ) );
     3589                return new WP_Error( 'invalid_key', __( 'Invalid key.' ) );
    35903590        }
    35913591
    35923592        if ( ! $key_request_time ) {
    3593                 return new WP_Error( 'invalid_key', __( 'Invalid action' ) );
     3593                return new WP_Error( 'invalid_key', __( 'Invalid action.' ) );
    35943594        }
    35953595
    35963596        /**
     
    36043604        $expiration_time     = $key_request_time + $expiration_duration;
    36053605
    36063606        if ( ! $wp_hasher->CheckPassword( $key, $saved_key ) ) {
    3607                 return new WP_Error( 'invalid_key', __( 'Invalid key' ) );
     3607                return new WP_Error( 'invalid_key', __( 'Invalid key.' ) );
    36083608        }
    36093609
    36103610        if ( ! $expiration_time || time() > $expiration_time ) {
  • src/wp-login.php

     
    852852
    853853        case 'confirmaction':
    854854                if ( ! isset( $_GET['request_id'] ) ) {
    855                         wp_die( __( 'Invalid request.' ) );
     855                        wp_die( __( 'Missing request ID.' ) );
    856856                }
    857857
     858                if ( ! isset( $_GET['confirm_key'] ) ) {
     859                        wp_die( __( 'Missing confirm key.' ) );
     860                }
     861
    858862                $request_id = (int) $_GET['request_id'];
     863                $key            = sanitize_text_field( wp_unslash( $_GET['confirm_key'] ) );
     864                $result         = wp_validate_user_request_key( $request_id, $key );
    859865
    860                 if ( isset( $_GET['confirm_key'] ) ) {
    861                         $key    = sanitize_text_field( wp_unslash( $_GET['confirm_key'] ) );
    862                         $result = wp_validate_user_request_key( $request_id, $key );
    863                 } else {
    864                         $result = new WP_Error( 'invalid_key', __( 'Invalid key' ) );
    865                 }
    866 
    867866                if ( is_wp_error( $result ) ) {
    868867                        wp_die( $result );
    869868                }