From d941cf62eea83204da4c785f3056c1c3e38aad55 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Tue, 19 Mar 2019 02:37:38 +0000 Subject: [PATCH] Privacy: Remove unnecessary `WP_Error` when handling `confirmaction` requests. By reordering the logic when handling the `confirmaction` action in `wp-login.php`, the need for a new `WP_Error` object to be created can be eliminated. The error message can be passed directly into a `wp_die()` call, matching the other validation errors in related code. Props garrett-eclipse, birgire. Fixes #44901. git-svn-id: https://develop.svn.wordpress.org/trunk@44931 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-login.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/wp-login.php b/src/wp-login.php index b02a2b9e70..464e4ed73f 100644 --- a/src/wp-login.php +++ b/src/wp-login.php @@ -853,17 +853,16 @@ switch ( $action ) { case 'confirmaction': if ( ! isset( $_GET['request_id'] ) ) { - wp_die( __( 'Invalid request.' ) ); + wp_die( __( 'Missing request ID.' ) ); + } + + if ( ! isset( $_GET['confirm_key'] ) ) { + wp_die( __( 'Missing confirm key.' ) ); } $request_id = (int) $_GET['request_id']; - - if ( isset( $_GET['confirm_key'] ) ) { - $key = sanitize_text_field( wp_unslash( $_GET['confirm_key'] ) ); - $result = wp_validate_user_request_key( $request_id, $key ); - } else { - $result = new WP_Error( 'invalid_key', __( 'Invalid key' ) ); - } + $key = sanitize_text_field( wp_unslash( $_GET['confirm_key'] ) ); + $result = wp_validate_user_request_key( $request_id, $key ); if ( is_wp_error( $result ) ) { wp_die( $result );