iliaa           Fri Nov  3 13:16:33 2006 UTC

  Modified files:              (Branch: PHP_5_2)
    /php-src    NEWS 
    /php-src/ext/json   json.c 
    /php-src/ext/json/tests     001.phpt fail001.phpt 
  Log:
  Fixed bug #38680 (Added missing handling of basic types in json_decode).
  
  # already in HEAD
  
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.317&r2=1.2027.2.547.2.318&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.317 php-src/NEWS:1.2027.2.547.2.318
--- php-src/NEWS:1.2027.2.547.2.317     Mon Oct 30 23:08:30 2006
+++ php-src/NEWS        Fri Nov  3 13:16:32 2006
@@ -1,6 +1,8 @@
 PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 2007, PHP 5.2.1
+- Fixed bug #38680 (Added missing handling of basic types in json_decode).
+  (Ilia) 
 
 02 Nov 2006, PHP 5.2.0
 - Updated bundled OpenSSL to version 0.9.8d in the Windows distro. (Edin)
http://cvs.php.net/viewvc.cgi/php-src/ext/json/json.c?r1=1.9.2.6&r2=1.9.2.7&diff_format=u
Index: php-src/ext/json/json.c
diff -u php-src/ext/json/json.c:1.9.2.6 php-src/ext/json/json.c:1.9.2.7
--- php-src/ext/json/json.c:1.9.2.6     Mon Aug 14 20:08:17 2006
+++ php-src/ext/json/json.c     Fri Nov  3 13:16:33 2006
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: json.c,v 1.9.2.6 2006/08/14 20:08:17 nlopess Exp $ */
+/* $Id: json.c,v 1.9.2.7 2006/11/03 13:16:33 iliaa Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -451,10 +451,37 @@
     }
     else
     {
+       double d;
+       int type;
+       long p;
+
         zval_dtor(z);
         FREE_ZVAL(z);
         efree(utf16);
-        RETURN_NULL();
+
+       if (parameter_len == 4) {
+               if (!strcasecmp(parameter, "null")) {
+                       RETURN_NULL();
+               } else if (!strcasecmp(parameter, "true")) {
+                       RETURN_BOOL(1);
+               }
+       } else if (parameter_len == 5 && !strcasecmp(parameter, "false")) {
+               RETURN_BOOL(0);
+       }
+       if ((type = is_numeric_string(parameter, parameter_len, &p, &d, 0)) != 
0) {
+               if (type == IS_LONG) {
+                       RETURN_LONG(p);
+               } else if (type == IS_DOUBLE) {
+                       RETURN_DOUBLE(d);
+               }
+       }
+       if (*parameter == '"' && parameter[parameter_len-1] == '"') {
+               RETURN_STRINGL(parameter+1, parameter_len-2, 1);
+       } else if (*parameter == '{' || *parameter == '[') { /* invalid JSON 
string */
+               RETURN_NULL();
+       } else {
+               RETURN_STRINGL(parameter, parameter_len, 1);
+       }
     }
 }
 
http://cvs.php.net/viewvc.cgi/php-src/ext/json/tests/001.phpt?r1=1.1.2.3&r2=1.1.2.4&diff_format=u
Index: php-src/ext/json/tests/001.phpt
diff -u php-src/ext/json/tests/001.phpt:1.1.2.3 
php-src/ext/json/tests/001.phpt:1.1.2.4
--- php-src/ext/json/tests/001.phpt:1.1.2.3     Thu Jul 20 08:56:57 2006
+++ php-src/ext/json/tests/001.phpt     Fri Nov  3 13:16:33 2006
@@ -31,12 +31,12 @@
 NULL
 NULL
 NULL
-NULL
-NULL
-NULL
-NULL
-NULL
-NULL
+string(1) "."
+string(1) "."
+string(3) "<?>"
+string(1) ";"
+string(12) "руссиш"
+string(4) "blah"
 NULL
 object(stdClass)#1 (1) {
   ["test"]=>
http://cvs.php.net/viewvc.cgi/php-src/ext/json/tests/fail001.phpt?r1=1.1.2.1&r2=1.1.2.2&diff_format=u
Index: php-src/ext/json/tests/fail001.phpt
diff -u php-src/ext/json/tests/fail001.phpt:1.1.2.1 
php-src/ext/json/tests/fail001.phpt:1.1.2.2
--- php-src/ext/json/tests/fail001.phpt:1.1.2.1 Mon Aug  7 23:28:05 2006
+++ php-src/ext/json/tests/fail001.phpt Fri Nov  3 13:16:33 2006
@@ -45,9 +45,9 @@
 --EXPECT--
 Testing: "A JSON payload should be an object or array, not a string."
 AS OBJECT
-NULL
+string(58) "A JSON payload should be an object or array, not a string."
 AS ARRAY
-NULL
+string(58) "A JSON payload should be an object or array, not a string."
 Testing: ["Unclosed array"
 AS OBJECT
 NULL
@@ -162,4 +162,4 @@
 AS OBJECT
 NULL
 AS ARRAY
-NULL
+NULL
\ No newline at end of file

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to