From f7560881f6922ebf8285b10ceac98b546d7d19bc Mon Sep 17 00:00:00 2001 From: Jani Taskinen Date: Tue, 22 Jul 2008 17:06:00 +0000 Subject: [PATCH] =?utf8?q?MFB:-=C3=82=C2=A0Fixed=20bug=20#38680=20(Added?= =?utf8?q?=20missing=20handling=20of=20basic=20types=20in=20json=5Fdecode)?= =?utf8?q?=20#=20This=20was=20claimed=20to=20be=20in=20HEAD=20but=20wasn't?= =?utf8?q?..some=20commit=20reverted=20it=20or=20#=20someone=20didn't=20ch?= =?utf8?q?eck=20for=20real..?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- ext/json/json.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ext/json/json.c b/ext/json/json.c index 347f100dcd..9f86daa004 100644 --- a/ext/json/json.c +++ b/ext/json/json.c @@ -545,6 +545,8 @@ static PHP_FUNCTION(json_decode) } if (str_len > 1 && *str.s == '"' && str.s[str_len-1] == '"') { RETURN_STRINGL(str.s+1, str_len-2, 1); + } else if (*str.s == '{' || *str.s == '[') { /* invalid JSON string */ + RETURN_NULL(); } else { RETURN_STRINGL(str.s, str_len, 1); } @@ -576,6 +578,8 @@ static PHP_FUNCTION(json_decode) } if (str_len > 1 && *str.u == 0x22 /*'"'*/ && str.u[str_len-1] == 0x22 /*'"'*/) { RETURN_UNICODEL(str.u+1, str_len-2, 1); + } else if (*str.u == 0x7b /*'{'*/ || *str.u == 0x5b /*'['*/ ) { /* invalid JSON string */ + RETURN_NULL(); } else { RETURN_UNICODEL(str.u, str_len, 1); } -- 2.50.1