Workaround PHP parse_url() bug. Props azaozz. fixes #7288

git-svn-id: http://svn.automattic.com/wordpress/trunk@8324 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-07-13 05:16:54 +00:00
parent 4846338eeb
commit 8750ed2ea1

View File

@ -827,7 +827,10 @@ function wp_safe_redirect($location, $status = 302) {
if ( substr($location, 0, 2) == '//' ) if ( substr($location, 0, 2) == '//' )
$location = 'http:' . $location; $location = 'http:' . $location;
$lp = parse_url($location); // In php 5 parse_url may fail if the URL query part contains http://, bug #38143
$test = ( $cut = strpos($location, '?') ) ? substr( $location, 0, $cut ) : $location;
$lp = parse_url($test);
$wpp = parse_url(get_option('home')); $wpp = parse_url(get_option('home'));
$allowed_hosts = (array) apply_filters('allowed_redirect_hosts', array($wpp['host']), isset($lp['host']) ? $lp['host'] : ''); $allowed_hosts = (array) apply_filters('allowed_redirect_hosts', array($wpp['host']), isset($lp['host']) ? $lp['host'] : '');