Browse Source

MFB fix for #41034

add missing tests
PHAR_1_2
Antony Dovgal 20 years ago
parent
commit
1607e9fa79
  1. 2
      ext/json/json.c
  2. 2
      ext/json/tests/002.phpt
  3. 12
      ext/json/tests/bug41034.phpt
  4. 23
      ext/json/tests/bug41067.phpt

2
ext/json/json.c

@ -176,7 +176,7 @@ static void json_encode_array(smart_str *buf, zval **val TSRMLS_DC) /* {{{ */
} else if (r == 1) {
if (i == HASH_KEY_IS_STRING ||
i == HASH_KEY_IS_UNICODE) {
if (key.s[0] == '\0') {
if (key.s[0] == '\0' && Z_TYPE_PP(val) == IS_OBJECT) {
/* Skip protected and private members. */
continue;
}

2
ext/json/tests/002.phpt

@ -21,7 +21,7 @@ echo "Done\n";
string(2) """"
string(4) "null"
string(4) "true"
string(2) "{}"
string(7) "{"":""}"
string(5) "[[1]]"
string(1) "1"
string(38) ""\u0440\u0443\u0441\u0441\u0438\u0448""

12
ext/json/tests/bug41034.phpt

@ -0,0 +1,12 @@
--TEST--
Bug #41034 (json_encode() ignores null byte started keys in arrays)
--SKIPIF--
<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
echo json_encode(array(0,"\0ab"=>1,"\0null-prefixed value"));
echo "\nDone\n";
?>
--EXPECT--
{"0":0,"\u0000ab":1,"1":"\u0000null-prefixed value"}
Done

23
ext/json/tests/bug41067.phpt

@ -0,0 +1,23 @@
--TEST--
Bug #41067 (json_encode() problem with UTF-16 input)
--SKIPIF--
<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
$single_barline = "\360\235\204\200";
$array = array($single_barline);
var_dump(bin2hex((binary)$single_barline));
$json = json_encode($array);
$json_decoded = json_decode($json, true);
var_dump(bin2hex((binary)$json_decoded[0]));
?>
--EXPECT--
string(8) "f09d8480"
string(8) "f09d8480"
--UEXPECT--
unicode(8) "f09d8480"
unicode(8) "f09d8480"
Loading…
Cancel
Save