]> granicus.if.org Git - php/commitdiff
Fixed bug #41034 (json_encode() ignores null byte started keys in arrays)
authorIlia Alshanetsky <iliaa@php.net>
Thu, 12 Apr 2007 19:40:38 +0000 (19:40 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 12 Apr 2007 19:40:38 +0000 (19:40 +0000)
NEWS
ext/json/json.c
ext/json/tests/002.phpt
ext/json/tests/bug41034.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 67da13e1996bc2f957ea4c0c765ed6667b08fe5c..6a44880d8350c0ae70125f13a20204a8353cdb81 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,8 @@ PHP                                                                        NEWS
 - Fixed bug #41063 (chdir doesn't like root paths). (Dmitry)
 - Fixed bug #41061 ("visibility error" in ReflectionFunction::export()).
   (Johannes)
+- Fixed bug #41034 (json_encode() ignores null byte started keys in arrays).
+  (Ilia)
 - Fixed bug #40861 (strtotime() doesn't handle double negative relative time
   units correctly). (Derick)
 
index 1bfe3e0743f0f3b2baa3bdef8c34fd75f01b69d4..809d005c57acc67d7c84c7fd8392147d4ec5e848 100644 (file)
@@ -177,7 +177,7 @@ static void json_encode_array(smart_str *buf, zval **val TSRMLS_DC) {
                     json_encode_r(buf, *data TSRMLS_CC);
                 } else if (r == 1) {
                     if (i == HASH_KEY_IS_STRING) {
-                        if (key[0] == '\0') {
+                        if (key[0] == '\0' && Z_TYPE_PP(val) == IS_OBJECT) {
                             /* Skip protected and private members. */
                             continue;
                         }
index 5bc29bc5b9598442aed518e60429688cdc921e21..87f57421f3c9c3416fdc6c51c4c1d85da3bedaff 100644 (file)
@@ -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""
diff --git a/ext/json/tests/bug41034.phpt b/ext/json/tests/bug41034.phpt
new file mode 100644 (file)
index 0000000..7a7e5f7
Binary files /dev/null and b/ext/json/tests/bug41034.phpt differ