WordPress.org

Make WordPress Core

Changeset 21865


Ignore:
Timestamp:
09/16/2012 04:16:26 PM (8 years ago)
Author:
nacin
Message:

Simplify protocol stripping in add_query_arg() by avoiding a regular expression. Don't cast a known array to an array. fixes #21332.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r21826 r21865  
    656656        $frag = '';
    657657
    658     if ( preg_match( '|^https?://|i', $uri, $matches ) ) {
    659         $protocol = $matches[0];
    660         $uri = substr( $uri, strlen( $protocol ) );
     658    if ( 0 === stripos( 'http://', $uri ) ) {
     659        $protocol = 'http://';
     660        $uri = substr( $uri, 7 );
     661    } elseif ( 0 === stripos( 'https://', $uri ) ) {
     662        $protocol = 'https://';
     663        $uri = substr( $uri, 8 );
    661664    } else {
    662665        $protocol = '';
     
    672675            $query = $parts[1];
    673676        }
    674     } elseif ( !empty( $protocol ) || strpos( $uri, '=' ) === false ) {
     677    } elseif ( $protocol || strpos( $uri, '=' ) === false ) {
    675678        $base = $uri . '?';
    676679        $query = '';
     
    689692    }
    690693
    691     foreach ( (array) $qs as $k => $v ) {
     694    foreach ( $qs as $k => $v ) {
    692695        if ( $v === false )
    693696            unset( $qs[$k] );
Note: See TracChangeset for help on using the changeset viewer.