mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-29 07:37:44 +02:00
General: wp_safe_redirect() and wp_redirect() shouldn't allow non-3xx status codes
Redirects should use redirect status codes and if you attempt to call wp_safe_redirect or wp_redirect with a non redirect status it can lead to undesired behavior and head scratching. Fixes #44317. Props spenserhale, johnbillion, mjnewman for initial patch. Built from https://develop.svn.wordpress.org/trunk@46641 git-svn-id: http://core.svn.wordpress.org/trunk@46441 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a87271af60
commit
946217dcca
@ -1215,6 +1215,7 @@ if ( ! function_exists( 'wp_redirect' ) ) :
|
|||||||
*
|
*
|
||||||
* @since 1.5.1
|
* @since 1.5.1
|
||||||
* @since 5.1.0 The `$x_redirect_by` parameter was added.
|
* @since 5.1.0 The `$x_redirect_by` parameter was added.
|
||||||
|
* @since 5.4.0 On invalid status codes, wp_die() is called.
|
||||||
*
|
*
|
||||||
* @global bool $is_IIS
|
* @global bool $is_IIS
|
||||||
*
|
*
|
||||||
@ -1250,6 +1251,10 @@ if ( ! function_exists( 'wp_redirect' ) ) :
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( 300 > $status || 399 < $status ) {
|
||||||
|
wp_die( __( 'HTTP redirect status code must be a redirection code, 3xx.' ) );
|
||||||
|
}
|
||||||
|
|
||||||
$location = wp_sanitize_redirect( $location );
|
$location = wp_sanitize_redirect( $location );
|
||||||
|
|
||||||
if ( ! $is_IIS && PHP_SAPI != 'cgi-fcgi' ) {
|
if ( ! $is_IIS && PHP_SAPI != 'cgi-fcgi' ) {
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.4-alpha-46640';
|
$wp_version = '5.4-alpha-46641';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user