Changes in trunk/wp-includes/class-json.php [12705:16340]
- File:
-
- 1 edited
-
trunk/wp-includes/class-json.php (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/class-json.php
r12705 r16340 154 154 } 155 155 156 $bytes = (ord($utf16 {0}) << 8) | ord($utf16{1});156 $bytes = (ord($utf16[0]) << 8) | ord($utf16[1]); 157 157 158 158 switch(true) { … … 207 207 // return a UTF-16 character from a 2-byte UTF-8 char 208 208 // 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]))); 212 212 213 213 case 3: 214 214 // return a UTF-16 character from a 3-byte UTF-8 char 215 215 // 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]))); 220 220 } 221 221 … … 294 294 for ($c = 0; $c < $strlen_var; ++$c) { 295 295 296 $ord_var_c = ord($var {$c});296 $ord_var_c = ord($var[$c]); 297 297 298 298 switch (true) { … … 317 317 case $ord_var_c == 0x5C: 318 318 // double quote, slash, slosh 319 $ascii .= '\\'.$var {$c};319 $ascii .= '\\'.$var[$c]; 320 320 break; 321 321 322 322 case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): 323 323 // characters U-00000000 - U-0000007F (same as ASCII) 324 $ascii .= $var {$c};324 $ascii .= $var[$c]; 325 325 break; 326 326 … … 334 334 } 335 335 336 $char = pack('C*', $ord_var_c, ord($var {$c + 1}));336 $char = pack('C*', $ord_var_c, ord($var[$c + 1])); 337 337 $c += 1; 338 338 $utf16 = $this->utf82utf16($char); … … 349 349 // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 350 350 $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])); 353 353 $c += 2; 354 354 $utf16 = $this->utf82utf16($char); … … 365 365 // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 366 366 $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])); 370 370 $c += 3; 371 371 $utf16 = $this->utf82utf16($char); … … 382 382 } 383 383 $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])); 388 388 $c += 4; 389 389 $utf16 = $this->utf82utf16($char); … … 400 400 // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 401 401 $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])); 407 407 $c += 5; 408 408 $utf16 = $this->utf82utf16($char); … … 578 578 579 579 $substr_chrs_c_2 = substr($chrs, $c, 2); 580 $ord_chrs_c = ord($chrs {$c});580 $ord_chrs_c = ord($chrs[$c]); 581 581 582 582 switch (true) { … … 608 608 if (($delim == '"' && $substr_chrs_c_2 != '\\\'') || 609 609 ($delim == "'" && $substr_chrs_c_2 != '\\"')) { 610 $utf8 .= $chrs {++$c};610 $utf8 .= $chrs[++$c]; 611 611 } 612 612 break; … … 621 621 622 622 case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F): 623 $utf8 .= $chrs {$c};623 $utf8 .= $chrs[$c]; 624 624 break; 625 625 … … 668 668 // array, or object notation 669 669 670 if ($str {0}== '[') {670 if ($str[0] == '[') { 671 671 $stk = array(SERVICES_JSON_IN_ARR); 672 672 $arr = array(); … … 707 707 $substr_chrs_c_2 = substr($chrs, $c, 2); 708 708 709 if (($c == $strlen_chrs) || (($chrs {$c}== ',') && ($top['what'] == SERVICES_JSON_SLICE))) {709 if (($c == $strlen_chrs) || (($chrs[$c] == ',') && ($top['what'] == SERVICES_JSON_SLICE))) { 710 710 // found a comma that is not inside a string, array, etc., 711 711 // OR we've reached the end of the character list … … 749 749 } 750 750 751 } elseif ((($chrs {$c} == '"') || ($chrs{$c}== "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {751 } elseif ((($chrs[$c] == '"') || ($chrs[$c] == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) { 752 752 // 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])); 754 754 //print("Found start of string at {$c}\n"); 755 755 756 } elseif (($chrs {$c}== $top['delim']) &&756 } elseif (($chrs[$c] == $top['delim']) && 757 757 ($top['what'] == SERVICES_JSON_IN_STR) && 758 758 ((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) { … … 763 763 //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n"); 764 764 765 } elseif (($chrs {$c}== '[') &&765 } elseif (($chrs[$c] == '[') && 766 766 in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { 767 767 // found a left-bracket, and we are in an array, object, or slice … … 769 769 //print("Found start of array at {$c}\n"); 770 770 771 } elseif (($chrs {$c}== ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {771 } elseif (($chrs[$c] == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) { 772 772 // found a right-bracket, and we're in an array 773 773 array_pop($stk); 774 774 //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); 775 775 776 } elseif (($chrs {$c}== '{') &&776 } elseif (($chrs[$c] == '{') && 777 777 in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { 778 778 // found a left-brace, and we are in an array, object, or slice … … 780 780 //print("Found start of object at {$c}\n"); 781 781 782 } elseif (($chrs {$c}== '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {782 } elseif (($chrs[$c] == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) { 783 783 // found a right-brace, and we're in an object 784 784 array_pop($stk);
Note: See TracChangeset
for help on using the changeset viewer.