WordPress.org

Make WordPress Core

Ticket #36998: 36998.1.diff

File 36998.1.diff, 1.3 KB (added by donmhico, 3 months ago)

Corrected the diff.

  • src/wp-includes/pluggable.php

    diff --git src/wp-includes/pluggable.php src/wp-includes/pluggable.php
    index 4edb9929f6..994be2c1c1 100644
    if ( ! function_exists( 'wp_sanitize_redirect' ) ) : 
    12711271         * @return string Redirect-sanitized URL.
    12721272         */
    12731273        function wp_sanitize_redirect( $location ) {
     1274                // Encode whitespaces.
     1275                $location = str_replace( ' ', '%20', $location );
     1276               
    12741277                $regex    = '/
    12751278                (
    12761279                        (?: [\xC2-\xDF][\x80-\xBF]        # double-byte sequences   110xxxxx 10xxxxxx
  • tests/phpunit/tests/pluggable.php

    diff --git tests/phpunit/tests/pluggable.php tests/phpunit/tests/pluggable.php
    index e711f3b8bc..28cc3cd462 100644
    class Tests_Pluggable extends WP_UnitTestCase { 
    319319                return $signatures;
    320320        }
    321321
     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
    322338}