Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-json.php

    r12705 r16340  
    154154        }
    155155
    156         $bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
     156        $bytes = (ord($utf16[0]) << 8) | ord($utf16[1]);
    157157
    158158        switch(true) {
     
    207207                // return a UTF-16 character from a 2-byte UTF-8 char
    208208                // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
    209                 return chr(0x07 & (ord($utf8{0}) >> 2))
    210                     . chr((0xC0 & (ord($utf8{0}) << 6))
    211                         | (0x3F & ord($utf8{1})));
     209                return chr(0x07 & (ord($utf8[0]) >> 2))
     210                    . chr((0xC0 & (ord($utf8[0]) << 6))
     211                        | (0x3F & ord($utf8[1])));
    212212
    213213            case 3:
    214214                // return a UTF-16 character from a 3-byte UTF-8 char
    215215                // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
    216                 return chr((0xF0 & (ord($utf8{0}) << 4))
    217                         | (0x0F & (ord($utf8{1}) >> 2)))
    218                     . chr((0xC0 & (ord($utf8{1}) << 6))
    219                         | (0x7F & ord($utf8{2})));
     216                return chr((0xF0 & (ord($utf8[0]) << 4))
     217                        | (0x0F & (ord($utf8[1]) >> 2)))
     218                    . chr((0xC0 & (ord($utf8[1]) << 6))
     219                        | (0x7F & ord($utf8[2])));
    220220        }
    221221
     
    294294                for ($c = 0; $c < $strlen_var; ++$c) {
    295295
    296                     $ord_var_c = ord($var{$c});
     296                    $ord_var_c = ord($var[$c]);
    297297
    298298                    switch (true) {
     
    317317                        case $ord_var_c == 0x5C:
    318318                            // double quote, slash, slosh
    319                             $ascii .= '\\'.$var{$c};
     319                            $ascii .= '\\'.$var[$c];
    320320                            break;
    321321
    322322                        case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
    323323                            // characters U-00000000 - U-0000007F (same as ASCII)
    324                             $ascii .= $var{$c};
     324                            $ascii .= $var[$c];
    325325                            break;
    326326
     
    334334                            }
    335335
    336                             $char = pack('C*', $ord_var_c, ord($var{$c + 1}));
     336                            $char = pack('C*', $ord_var_c, ord($var[$c + 1]));
    337337                            $c += 1;
    338338                            $utf16 = $this->utf82utf16($char);
     
    349349                            // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
    350350                            $char = pack('C*', $ord_var_c,
    351                                         @ord($var{$c + 1}),
    352                                         @ord($var{$c + 2}));
     351                                        @ord($var[$c + 1]),
     352                                        @ord($var[$c + 2]));
    353353                            $c += 2;
    354354                            $utf16 = $this->utf82utf16($char);
     
    365365                            // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
    366366                            $char = pack('C*', $ord_var_c,
    367                                         ord($var{$c + 1}),
    368                                         ord($var{$c + 2}),
    369                                         ord($var{$c + 3}));
     367                                        ord($var[$c + 1]),
     368                                        ord($var[$c + 2]),
     369                                        ord($var[$c + 3]));
    370370                            $c += 3;
    371371                            $utf16 = $this->utf82utf16($char);
     
    382382                            }
    383383                            $char = pack('C*', $ord_var_c,
    384                                         ord($var{$c + 1}),
    385                                         ord($var{$c + 2}),
    386                                         ord($var{$c + 3}),
    387                                         ord($var{$c + 4}));
     384                                        ord($var[$c + 1]),
     385                                        ord($var[$c + 2]),
     386                                        ord($var[$c + 3]),
     387                                        ord($var[$c + 4]));
    388388                            $c += 4;
    389389                            $utf16 = $this->utf82utf16($char);
     
    400400                            // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
    401401                            $char = pack('C*', $ord_var_c,
    402                                         ord($var{$c + 1}),
    403                                         ord($var{$c + 2}),
    404                                         ord($var{$c + 3}),
    405                                         ord($var{$c + 4}),
    406                                         ord($var{$c + 5}));
     402                                        ord($var[$c + 1]),
     403                                        ord($var[$c + 2]),
     404                                        ord($var[$c + 3]),
     405                                        ord($var[$c + 4]),
     406                                        ord($var[$c + 5]));
    407407                            $c += 5;
    408408                            $utf16 = $this->utf82utf16($char);
     
    578578
    579579                        $substr_chrs_c_2 = substr($chrs, $c, 2);
    580                         $ord_chrs_c = ord($chrs{$c});
     580                        $ord_chrs_c = ord($chrs[$c]);
    581581
    582582                        switch (true) {
     
    608608                                if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
    609609                                ($delim == "'" && $substr_chrs_c_2 != '\\"')) {
    610                                     $utf8 .= $chrs{++$c};
     610                                    $utf8 .= $chrs[++$c];
    611611                                }
    612612                                break;
     
    621621
    622622                            case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
    623                                 $utf8 .= $chrs{$c};
     623                                $utf8 .= $chrs[$c];
    624624                                break;
    625625
     
    668668                    // array, or object notation
    669669
    670                     if ($str{0} == '[') {
     670                    if ($str[0] == '[') {
    671671                        $stk = array(SERVICES_JSON_IN_ARR);
    672672                        $arr = array();
     
    707707                        $substr_chrs_c_2 = substr($chrs, $c, 2);
    708708
    709                         if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
     709                        if (($c == $strlen_chrs) || (($chrs[$c] == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
    710710                            // found a comma that is not inside a string, array, etc.,
    711711                            // OR we've reached the end of the character list
     
    749749                            }
    750750
    751                         } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
     751                        } elseif ((($chrs[$c] == '"') || ($chrs[$c] == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
    752752                            // found a quote, and we are not inside a string
    753                             array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
     753                            array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs[$c]));
    754754                            //print("Found start of string at {$c}\n");
    755755
    756                         } elseif (($chrs{$c} == $top['delim']) &&
     756                        } elseif (($chrs[$c] == $top['delim']) &&
    757757                                ($top['what'] == SERVICES_JSON_IN_STR) &&
    758758                                ((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
     
    763763                            //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
    764764
    765                         } elseif (($chrs{$c} == '[') &&
     765                        } elseif (($chrs[$c] == '[') &&
    766766                                in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
    767767                            // found a left-bracket, and we are in an array, object, or slice
     
    769769                            //print("Found start of array at {$c}\n");
    770770
    771                         } elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
     771                        } elseif (($chrs[$c] == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
    772772                            // found a right-bracket, and we're in an array
    773773                            array_pop($stk);
    774774                            //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
    775775
    776                         } elseif (($chrs{$c} == '{') &&
     776                        } elseif (($chrs[$c] == '{') &&
    777777                                in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
    778778                            // found a left-brace, and we are in an array, object, or slice
     
    780780                            //print("Found start of object at {$c}\n");
    781781
    782                         } elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
     782                        } elseif (($chrs[$c] == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
    783783                            // found a right-brace, and we're in an object
    784784                            array_pop($stk);
Note: See TracChangeset for help on using the changeset viewer.