tony2001 Mon Apr 23 10:48:13 2007 UTC
Modified files:
/php-src/ext/json json.c
/php-src/ext/json/tests bug41034.phpt bug41067.phpt 002.phpt
Log:
MFB fix for #41034
add missing tests
http://cvs.php.net/viewvc.cgi/php-src/ext/json/json.c?r1=1.24&r2=1.25&diff_format=u
Index: php-src/ext/json/json.c
diff -u php-src/ext/json/json.c:1.24 php-src/ext/json/json.c:1.25
--- php-src/ext/json/json.c:1.24 Mon Apr 16 16:52:20 2007
+++ php-src/ext/json/json.c Mon Apr 23 10:48:13 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: json.c,v 1.24 2007/04/16 16:52:20 andrei Exp $ */
+/* $Id: json.c,v 1.25 2007/04/23 10:48:13 tony2001 Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -176,7 +176,7 @@
} 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;
}
http://cvs.php.net/viewvc.cgi/php-src/ext/json/tests/bug41034.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/json/tests/bug41034.phpt
diff -u /dev/null php-src/ext/json/tests/bug41034.phpt:1.2
--- /dev/null Mon Apr 23 10:48:13 2007
+++ php-src/ext/json/tests/bug41034.phpt Mon Apr 23 10:48:13 2007
@@ -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
http://cvs.php.net/viewvc.cgi/php-src/ext/json/tests/bug41067.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/json/tests/bug41067.phpt
diff -u /dev/null php-src/ext/json/tests/bug41067.phpt:1.2
--- /dev/null Mon Apr 23 10:48:13 2007
+++ php-src/ext/json/tests/bug41067.phpt Mon Apr 23 10:48:13 2007
@@ -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"
http://cvs.php.net/viewvc.cgi/php-src/ext/json/tests/002.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/json/tests/002.phpt
diff -u php-src/ext/json/tests/002.phpt:1.1 php-src/ext/json/tests/002.phpt:1.2
--- php-src/ext/json/tests/002.phpt:1.1 Thu Jul 20 08:56:24 2006
+++ php-src/ext/json/tests/002.phpt Mon Apr 23 10:48:13 2007
@@ -21,7 +21,7 @@
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""
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php