~canonical-sysadmins/wordpress/4.4.2

« back to all changes in this revision

Viewing changes to wp-includes/pluggable.php

  • Committer: Haw Loeung
  • Date: 2016-02-03 02:21:54 UTC
  • mfrom: (1.1.13 upstream)
  • Revision ID: haw.loeung@canonical.com-20160203022154-0xy5mh0a1wc09e1f
Merge WP4.4.2 from upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1333
1333
        // In php 5 parse_url may fail if the URL query part contains http://, bug #38143
1334
1334
        $test = ( $cut = strpos($location, '?') ) ? substr( $location, 0, $cut ) : $location;
1335
1335
 
1336
 
        $lp  = parse_url($test);
 
1336
        // @-operator is used to prevent possible warnings in PHP < 5.3.3.
 
1337
        $lp = @parse_url($test);
1337
1338
 
1338
1339
        // Give up if malformed URL
1339
1340
        if ( false === $lp )
1343
1344
        if ( isset($lp['scheme']) && !('http' == $lp['scheme'] || 'https' == $lp['scheme']) )
1344
1345
                return $default;
1345
1346
 
1346
 
        // Reject if scheme is set but host is not. This catches urls like https:host.com for which parse_url does not set the host field.
1347
 
        if ( isset($lp['scheme'])  && !isset($lp['host']) )
 
1347
        // Reject if certain components are set but host is not. This catches urls like https:host.com for which parse_url does not set the host field.
 
1348
        if ( ! isset( $lp['host'] ) && ( isset( $lp['scheme'] ) || isset( $lp['user'] ) || isset( $lp['pass'] ) || isset( $lp['port'] ) ) ) {
1348
1349
                return $default;
 
1350
        }
 
1351
 
 
1352
        // Reject malformed components parse_url() can return on odd inputs
 
1353
        foreach ( array( 'user', 'pass', 'host' ) as $component ) {
 
1354
                if ( isset( $lp[ $component ] ) && strpbrk( $lp[ $component ], ':/?#@' ) ) {
 
1355
                        return $default;
 
1356
                }
 
1357
        }
1349
1358
 
1350
1359
        $wpp = parse_url(home_url());
1351
1360