Make WordPress Core

Changeset 40190


Ignore:
Timestamp:
03/06/2017 01:43:50 PM (10 years ago)
Author:
aaroncampbell
Message:

Strip control characters before validating redirect.

Merges [40183] to 4.1 branch.

Location:
branches/4.1
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.1

  • branches/4.1/src/wp-includes/pluggable.php

    r37762 r40190  
    12411241 **/
    12421242function wp_validate_redirect($location, $default = '') {
    1243         $location = trim( $location );
     1243        $location = trim( $location, " \t\n\r\0\x08\x0B" );
    12441244        // browsers will assume 'http' is your protocol, and will obey a redirect to a URL starting with '//'
    12451245        if ( substr($location, 0, 2) == '//' )
  • branches/4.1/tests/phpunit/tests/formatting/redirect.php

    r36450 r40190  
    5858                        array( 'http://user:@example.com/', 'http://user:@example.com/' ),
    5959                        array( 'http://user:pass@example.com/', 'http://user:pass@example.com/' ),
     60                        array( " \t\n\r\0\x08\x0Bhttp://example.com", 'http://example.com' ),
     61                        array( " \t\n\r\0\x08\x0B//example.com", 'http://example.com' ),
    6062                );
    6163        }
     
    6971                        // non-safelisted domain
    7072                        array( 'http://non-safelisted.example/' ),
     73
     74                        // non-safelisted domain (leading whitespace)
     75                        array( " \t\n\r\0\x08\x0Bhttp://non-safelisted.example.com" ),
     76                        array( " \t\n\r\0\x08\x0B//non-safelisted.example.com" ),
    7177
    7278                        // unsupported schemes
Note: See TracChangeset for help on using the changeset viewer.