summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkovacs.ferenc <kovacs.ferenc@ustream.tv>2013-11-18 12:39:40 +0100
committerkovacs.ferenc <kovacs.ferenc@ustream.tv>2013-11-18 12:39:40 +0100
commita833f7d460f6b620270f19f622ca45a627b339c1 (patch)
treed49034decd84244185c83c9f223e17cabcccfa69
parent9e3551ba1f00baa4a14215fda0c5d28aecfcdeba (diff)
parent2042d78fce4175c6b6b3dbc5f99bdd9caf213811 (diff)
downloadphp-git-a833f7d460f6b620270f19f622ca45a627b339c1.tar.gz
Merge branch 'PHP-5.6'
-rw-r--r--ext/json/json.c6
-rw-r--r--ext/json/tests/bug64874_part2.phpt69
2 files changed, 72 insertions, 3 deletions
diff --git a/ext/json/json.c b/ext/json/json.c
index 5517da601d..d017753de6 100644
--- a/ext/json/json.c
+++ b/ext/json/json.c
@@ -712,14 +712,14 @@ PHP_JSON_API void php_json_decode_ex(zval *return_value, char *str, int str_len,
RETVAL_NULL();
if (trim_len == 4) {
- if (!strncasecmp(trim, "null", trim_len)) {
+ if (!strncmp(trim, "null", trim_len)) {
/* We need to explicitly clear the error because its an actual NULL and not an error */
jp->error_code = PHP_JSON_ERROR_NONE;
RETVAL_NULL();
- } else if (!strncasecmp(trim, "true", trim_len)) {
+ } else if (!strncmp(trim, "true", trim_len)) {
RETVAL_BOOL(1);
}
- } else if (trim_len == 5 && !strncasecmp(trim, "false", trim_len)) {
+ } else if (trim_len == 5 && !strncmp(trim, "false", trim_len)) {
RETVAL_BOOL(0);
}
diff --git a/ext/json/tests/bug64874_part2.phpt b/ext/json/tests/bug64874_part2.phpt
new file mode 100644
index 0000000000..338fc1141a
--- /dev/null
+++ b/ext/json/tests/bug64874_part2.phpt
@@ -0,0 +1,69 @@
+--TEST--
+Case-sensitivity part of bug #64874 ("json_decode handles whitespace and case-sensitivity incorrectly")
+--SKIPIF--
+<?php if (!extension_loaded("json")) print "skip"; ?>
+--FILE--
+<?php
+function decode($json) {
+ var_dump(json_decode($json));
+ echo ((json_last_error() !== 0) ? 'ERROR' : 'SUCCESS') . PHP_EOL;
+}
+
+// Only lowercase should work
+decode('true');
+decode('True');
+decode('[true]');
+decode('[True]');
+echo PHP_EOL;
+
+decode('false');
+decode('False');
+decode('[false]');
+decode('[False]');
+echo PHP_EOL;
+
+decode('null');
+decode('Null');
+decode('[null]');
+decode('[Null]');
+echo PHP_EOL;
+
+echo "Done\n";
+--EXPECT--
+bool(true)
+SUCCESS
+NULL
+ERROR
+array(1) {
+ [0]=>
+ bool(true)
+}
+SUCCESS
+NULL
+ERROR
+
+bool(false)
+SUCCESS
+NULL
+ERROR
+array(1) {
+ [0]=>
+ bool(false)
+}
+SUCCESS
+NULL
+ERROR
+
+NULL
+SUCCESS
+NULL
+ERROR
+array(1) {
+ [0]=>
+ NULL
+}
+SUCCESS
+NULL
+ERROR
+
+Done