Skip to content

Commit c86ee39

Browse files
Improve URL validation in wp_validate_redirect().
Props vortfu, whyisjake, peterwilsoncc. Built from https://develop.svn.wordpress.org/trunk@45971 git-svn-id: http://core.svn.wordpress.org/trunk@45782 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 parent 187d747 commit c86ee39

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Diff for: wp-includes/pluggable.php

+8
Original file line numberDiff line numberDiff line change
@@ -1407,6 +1407,14 @@ function wp_validate_redirect( $location, $default = '' ) {
14071407
return $default;
14081408
}
14091409

1410+
if ( ! isset( $lp['host'] ) && ! empty( $lp['path'] ) && '/' !== $lp['path'][0] ) {
1411+
$path = '';
1412+
if ( ! empty( $_SERVER['REQUEST_URI'] ) ) {
1413+
$path = dirname( parse_url( 'http://placeholder' . $_SERVER['REQUEST_URI'], PHP_URL_PATH ) . '?' );
1414+
}
1415+
$location = '/' . ltrim( $path . '/', '/' ) . $location;
1416+
}
1417+
14101418
// Reject if certain components are set but host is not. This catches urls like https:host.com for which parse_url does not set the host field.
14111419
if ( ! isset( $lp['host'] ) && ( isset( $lp['scheme'] ) || isset( $lp['user'] ) || isset( $lp['pass'] ) || isset( $lp['port'] ) ) ) {
14121420
return $default;

Diff for: wp-includes/version.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
* @global string $wp_version
1515
*/
16-
$wp_version = '5.3-alpha-45964';
16+
$wp_version = '5.3-alpha-45971';
1717

1818
/**
1919
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

0 commit comments

Comments
 (0)