mirror of
git://develop.git.wordpress.org/
synced 2025-01-17 21:08:44 +01:00
Improve URL validation in wp_validate_redirect()
.
Merges [45971] to the 4.7 branch. Props vortfu, whyisjake, peterwilsoncc. git-svn-id: https://develop.svn.wordpress.org/branches/4.7@45977 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
707096e9e0
commit
57f85ba712
@ -1318,6 +1318,14 @@ function wp_validate_redirect($location, $default = '') {
|
||||
if ( isset($lp['scheme']) && !('http' == $lp['scheme'] || 'https' == $lp['scheme']) )
|
||||
return $default;
|
||||
|
||||
if ( ! isset( $lp['host'] ) && ! empty( $lp['path'] ) && '/' !== $lp['path'][0] ) {
|
||||
$path = '';
|
||||
if ( ! empty( $_SERVER['REQUEST_URI'] ) ) {
|
||||
$path = dirname( parse_url( 'http://placeholder' . $_SERVER['REQUEST_URI'], PHP_URL_PATH ) . '?' );
|
||||
}
|
||||
$location = '/' . ltrim( $path . '/', '/' ) . $location;
|
||||
}
|
||||
|
||||
// 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.
|
||||
if ( ! isset( $lp['host'] ) && ( isset( $lp['scheme'] ) || isset( $lp['user'] ) || isset( $lp['pass'] ) || isset( $lp['port'] ) ) ) {
|
||||
return $default;
|
||||
|
Loading…
x
Reference in New Issue
Block a user