]> granicus.if.org Git - php/commitdiff
MFH Fix bug #45989 - json_decode() doesn't return NULL on certain invalid strings
authorScott MacVicar <scottmac@php.net>
Fri, 12 Dec 2008 23:19:47 +0000 (23:19 +0000)
committerScott MacVicar <scottmac@php.net>
Fri, 12 Dec 2008 23:19:47 +0000 (23:19 +0000)
ext/json/json.c
ext/json/tests/001.phpt
ext/json/tests/bug42090.phpt

index b52b3ff5f3d42011cad2b74e8d3dcdebb83f778e..24afcdf560772ab41629b1667972fa66d8c82dc6 100644 (file)
@@ -523,13 +523,7 @@ static PHP_FUNCTION(json_decode)
                                RETURN_DOUBLE(d);
                        }
                }
-               if (str_len > 1 && *str == '"' && str[str_len-1] == '"') {
-                       RETURN_STRINGL(str+1, str_len-2, 1);
-               } else if (*str == '{' || *str == '[') { /* invalid JSON string */
-                       RETURN_NULL();
-               } else {
-                       RETURN_STRINGL(str, str_len, 1);
-               }
+               RETURN_NULL();
        }
 }
 /* }}} */
index 4c9f918b4888786c003d041bf0e345103679bb2f..095aedf631965773c9d1700b363ae6b669fa40a4 100644 (file)
@@ -31,12 +31,12 @@ NULL
 NULL
 NULL
 NULL
-string(1) "."
-string(1) "."
-string(3) "<?>"
-string(1) ";"
-string(12) "руссиш"
-string(4) "blah"
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
 NULL
 object(stdClass)#1 (1) {
   ["test"]=>
index daa57c3474bb777e6d032e457764abddcfb9de63..9e5b3317e5411abe6e652e95a70b49e01d8b6d2b 100644 (file)
@@ -16,10 +16,9 @@ var_dump(
 ?>
 --EXPECT--
 string(0) ""
-string(5) "".."."
-string(1) """
-string(2) """"
+NULL
+NULL
+NULL
 string(4) ""\"""
 string(1) """
 string(2) """"
-