Make WordPress Core


Ignore:
Timestamp:
09/10/2013 06:07:19 PM (11 years ago)
Author:
nacin
Message:

Better protocol validation in set_url_scheme().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/link-template.php

    r25310 r25319  
    22412241    }
    22422242
    2243     if ( 'relative' == $scheme )
    2244         $url = preg_replace( '#^.+://[^/]*#', '', $url );
    2245     else
    2246         $url = preg_replace( '#^.+://#', $scheme . '://', $url );
     2243    $url = trim( $url );
     2244    if ( $url[0] === '/' && $url[1] === '/' )
     2245        $url = 'http:' . $url;
     2246
     2247    if ( 'relative' == $scheme ) {
     2248        $url = ltrim( preg_replace( '#^\w+://[^/]*#', '', $url ) );
     2249        if ( $url[0] === '/' )
     2250            $url = '/' . ltrim($url , "/ \t\n\r\0\x0B" );
     2251    } else {
     2252        $url = preg_replace( '#^\w+://#', $scheme . '://', $url );
     2253    }
    22472254
    22482255    return apply_filters( 'set_url_scheme', $url, $scheme, $orig_scheme );
Note: See TracChangeset for help on using the changeset viewer.