Improve redirect handling
Merges[40689] to the 4.7 branch. git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40690 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
40ece6751b
commit
8a28180db9
@ -306,6 +306,11 @@ class WP_Http {
|
|||||||
// Ensure redirects follow browser behaviour.
|
// Ensure redirects follow browser behaviour.
|
||||||
$options['hooks']->register( 'requests.before_redirect', array( get_class(), 'browser_redirect_compatibility' ) );
|
$options['hooks']->register( 'requests.before_redirect', array( get_class(), 'browser_redirect_compatibility' ) );
|
||||||
|
|
||||||
|
// Validate redirected URLs.
|
||||||
|
if ( function_exists( 'wp_kses_bad_protocol' ) && $r['reject_unsafe_urls'] ) {
|
||||||
|
$options['hooks']->register( 'requests.before_redirect', array( get_class(), 'validate_redirects' ) );
|
||||||
|
}
|
||||||
|
|
||||||
if ( $r['stream'] ) {
|
if ( $r['stream'] ) {
|
||||||
$options['filename'] = $r['filename'];
|
$options['filename'] = $r['filename'];
|
||||||
}
|
}
|
||||||
@ -466,6 +471,20 @@ class WP_Http {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate redirected URLs.
|
||||||
|
*
|
||||||
|
* @since 4.7.5
|
||||||
|
*
|
||||||
|
* @throws Requests_Exception On unsuccessful URL validation
|
||||||
|
* @param string $location URL to redirect to.
|
||||||
|
*/
|
||||||
|
public static function validate_redirects( $location ) {
|
||||||
|
if ( ! wp_http_validate_url( $location ) ) {
|
||||||
|
throw new Requests_Exception( __('A valid URL was not provided.'), 'wp_http.redirect_failed_validation' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests which transports are capable of supporting the request.
|
* Tests which transports are capable of supporting the request.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user