} 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;
}
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""
--- /dev/null
+--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
--- /dev/null
+--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"