mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-02 05:31:25 +01:00
Restrict schemes allowed in wp_validate_redirect()
git-svn-id: http://svn.automattic.com/wordpress/trunk@13657 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
97a8320fe7
commit
2486cc70f7
@ -984,6 +984,15 @@ function wp_validate_redirect($location, $default = '') {
|
||||
$test = ( $cut = strpos($location, '?') ) ? substr( $location, 0, $cut ) : $location;
|
||||
|
||||
$lp = parse_url($test);
|
||||
|
||||
// Give up if malformed URL
|
||||
if ( false === $lp )
|
||||
return $default;
|
||||
|
||||
// Allow only http and https schemes. No data:, etc.
|
||||
if ( isset($lp['scheme']) && !('http' == $lp['scheme'] || 'https' == $lp['scheme']) )
|
||||
return $default;
|
||||
|
||||
$wpp = parse_url(home_url());
|
||||
|
||||
$allowed_hosts = (array) apply_filters('allowed_redirect_hosts', array($wpp['host']), isset($lp['host']) ? $lp['host'] : '');
|
||||
|
Loading…
Reference in New Issue
Block a user