Login and Registration: Check that `redirect_to` is a string in `wp-login.php`.

This prevents a fatal error if an array is passed instead.

Follow-up to [2876], [4969], [7524], [8701], [25701], [31417], [49109].

Props TimoTijhof.
Fixes #59373.
Built from https://develop.svn.wordpress.org/trunk@58023


git-svn-id: http://core.svn.wordpress.org/trunk@57489 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2024-04-18 06:24:22 +00:00
parent f6fae87e73
commit 3c5da9c743
2 changed files with 8 additions and 5 deletions

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.6-alpha-58022';
$wp_version = '6.6-alpha-58023';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -792,7 +792,7 @@ switch ( $action ) {
wp_logout();
if ( ! empty( $_REQUEST['redirect_to'] ) ) {
if ( ! empty( $_REQUEST['redirect_to'] ) && is_string( $_REQUEST['redirect_to'] ) ) {
$redirect_to = $_REQUEST['redirect_to'];
$requested_redirect_to = $redirect_to;
} else {
@ -1296,7 +1296,7 @@ switch ( $action ) {
}
}
if ( isset( $_REQUEST['redirect_to'] ) ) {
if ( isset( $_REQUEST['redirect_to'] ) && is_string( $_REQUEST['redirect_to'] ) ) {
$redirect_to = $_REQUEST['redirect_to'];
// Redirect to HTTPS if user wants SSL.
if ( $secure_cookie && str_contains( $redirect_to, 'wp-admin' ) ) {
@ -1334,7 +1334,8 @@ switch ( $action ) {
}
}
$requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
$requested_redirect_to = isset( $_REQUEST['redirect_to'] ) && is_string( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
/**
* Filters the login redirect URL.
*
@ -1438,7 +1439,9 @@ switch ( $action ) {
$errors->add( 'updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to see what&#8217;s new.' ), 'message' );
} elseif ( WP_Recovery_Mode_Link_Service::LOGIN_ACTION_ENTERED === $action ) {
$errors->add( 'enter_recovery_mode', __( 'Recovery Mode Initialized. Please log in to continue.' ), 'message' );
} elseif ( isset( $_GET['redirect_to'] ) && str_contains( $_GET['redirect_to'], 'wp-admin/authorize-application.php' ) ) {
} elseif ( isset( $_GET['redirect_to'] ) && is_string( $_GET['redirect_to'] )
&& str_contains( $_GET['redirect_to'], 'wp-admin/authorize-application.php' )
) {
$query_component = wp_parse_url( $_GET['redirect_to'], PHP_URL_QUERY );
$query = array();
if ( $query_component ) {