Make WordPress Core


Ignore:
Timestamp:
09/08/2007 02:27:24 PM (17 years ago)
Author:
markjaquith
Message:

Only urlencode previously existing values in add_query_arg() (more backwards compatible). fixes #4935. see #4084. see #4878

File:
1 edited

Legend:

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

    r5999 r6064  
    106106
    107107// from php.net (modified by Mark Jaquith to behave like the native PHP5 function)
    108 function _http_build_query($data, $prefix=null, $sep=null, $key='') {
     108function _http_build_query($data, $prefix=null, $sep=null, $key='', $urlencode=true) {
    109109    $ret = array();
     110    if ( $urlencode ) {
     111        $lsb = '%5B';
     112        $rsb = '%5D';
     113    } else {
     114        $lsb = '[';
     115        $rsb = ']';
     116    }
    110117    foreach ( (array) $data as $k => $v ) {
    111         $k = urlencode($k);
     118        if ( $urlencode)
     119            $k = urlencode($k);
    112120        if ( is_int($k) && $prefix != null )
    113121            $k = $prefix.$k;
    114122        if ( !empty($key) )
    115123            $k = $key . '%5B' . $k . '%5D';
    116 
    117124        if ( $v === NULL )
    118125            continue;
     
    121128
    122129        if ( is_array($v) || is_object($v) )
    123             array_push($ret,_http_build_query($v, '', $sep, $k));
     130            array_push($ret,_http_build_query($v, '', $sep, $k, $urlencode));
     131        elseif ( $urlencode )
     132            array_push($ret, $k.'='.urlencode($v));
    124133        else
    125             array_push($ret, $k.'='.urlencode($v));
    126         }
     134            array_push($ret, $k.'='.$v);
     135    }
    127136
    128137    if ( NULL === $sep )
Note: See TracChangeset for help on using the changeset viewer.