diff --git src/wp-includes/pluggable.php src/wp-includes/pluggable.php
index 4edb9929f6..994be2c1c1 100644
|
|
|
if ( ! function_exists( 'wp_sanitize_redirect' ) ) : |
| 1271 | 1271 | * @return string Redirect-sanitized URL. |
| 1272 | 1272 | */ |
| 1273 | 1273 | function wp_sanitize_redirect( $location ) { |
| | 1274 | // Encode whitespaces. |
| | 1275 | $location = str_replace( ' ', '%20', $location ); |
| | 1276 | |
| 1274 | 1277 | $regex = '/ |
| 1275 | 1278 | ( |
| 1276 | 1279 | (?: [\xC2-\xDF][\x80-\xBF] # double-byte sequences 110xxxxx 10xxxxxx |
diff --git tests/phpunit/tests/pluggable.php tests/phpunit/tests/pluggable.php
index e711f3b8bc..28cc3cd462 100644
|
|
|
class Tests_Pluggable extends WP_UnitTestCase { |
| 319 | 319 | return $signatures; |
| 320 | 320 | } |
| 321 | 321 | |
| | 322 | /** |
| | 323 | * @group 36998 |
| | 324 | */ |
| | 325 | function test_wp_sanitize_redirect_should_encode_whitespaces() { |
| | 326 | |
| | 327 | $test_expected_and_values = [ |
| | 328 | 'http://example.com/test%20whitespaces' => 'http://example.com/test%20whitespaces', |
| | 329 | 'http://example.com/test%20whitespaces%20in%20url' => 'http://example.com/test whitespaces in url' |
| | 330 | ]; |
| | 331 | |
| | 332 | foreach( $test_expected_and_values as $expected => $value ) { |
| | 333 | $this->assertSame( $expected, wp_sanitize_redirect( $value ) ); |
| | 334 | } |
| | 335 | |
| | 336 | } |
| | 337 | |
| 322 | 338 | } |