WordPress.org

Make WordPress Core

Ticket #36998: 36998.diff

File 36998.diff, 1.3 KB (added by donmhico, 4 months ago)

Encoded whitespaces + unit test.

Line 
1diff --cc src/wp-includes/pluggable.php
2index 994be2c1c1,994be2c1c1,994be2c1c1..4edb9929f6
3--- src/wp-includes/pluggable.php
4+++ src/wp-includes/pluggable.php
5@@@@ -1271,9 -1271,9 -1271,9 +1271,6 @@@@ if ( ! function_exists( 'wp_sanitize_re
6         * @return string Redirect-sanitized URL.
7         */
8        function wp_sanitize_redirect( $location ) {
9---             // Encode whitespaces.
10---             $location = str_replace( ' ', '%20', $location );
11---             
12                $regex    = '/
13                (
14                        (?: [\xC2-\xDF][\x80-\xBF]        # double-byte sequences   110xxxxx 10xxxxxx
15diff --cc tests/phpunit/tests/pluggable.php
16index 28cc3cd462,28cc3cd462,28cc3cd462..e711f3b8bc
17--- tests/phpunit/tests/pluggable.php
18+++ tests/phpunit/tests/pluggable.php
19@@@@ -319,20 -319,20 -319,20 +319,4 @@@@ class Tests_Pluggable extends WP_UnitTe
20                return $signatures;
21        }
22   
23---     /**
24---      * @group 36998
25---      */
26---     function test_wp_sanitize_redirect_should_encode_whitespaces() {
27---
28---             $test_expected_and_values = [
29---                     'http://example.com/test%20whitespaces' => 'http://example.com/test%20whitespaces',
30---                     'http://example.com/test%20whitespaces%20in%20url' => 'http://example.com/test whitespaces in url'
31---             ];
32---
33---             foreach( $test_expected_and_values as $expected => $value ) {
34---                     $this->assertSame( $expected, wp_sanitize_redirect( $value ) );
35---             }
36---
37---     }
38---
39   }