diff options
author | Jakub Zelenka <bukka@php.net> | 2015-06-28 18:09:10 +0100 |
---|---|---|
committer | Jakub Zelenka <bukka@php.net> | 2015-06-28 18:09:10 +0100 |
commit | f30503ce4e0482d638a2561ca3ddc6e1291a104a (patch) | |
tree | d154ffe04fa8bd522e685cb051f83aa061e1e625 /ext/json/json_scanner.re | |
parent | fb08798c9f0ea820d567668d0cea4833dc61dd8e (diff) | |
download | php-git-f30503ce4e0482d638a2561ca3ddc6e1291a104a.tar.gz |
Fix incompatible JSON errors
This fixes differences in error codes with PHP 5 and 7.
The malformed UTF-8 and control character error codes are
now returned even in non-string context which makes it
the same as it was in PHP 5 json ext.
Diffstat (limited to 'ext/json/json_scanner.re')
-rw-r--r-- | ext/json/json_scanner.re | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/ext/json/json_scanner.re b/ext/json/json_scanner.re index 82cf69b457..1a8a68dca8 100644 --- a/ext/json/json_scanner.re +++ b/ext/json/json_scanner.re @@ -138,7 +138,7 @@ std: UTF16_2 = UTFPREF "0" HEX7 HEX{2} ; UTF16_3 = UTFPREF ( ( ( HEXC | [efEF] ) HEX ) | ( [dD] HEX7 ) ) HEX{2} ; UTF16_4 = UTFPREF [dD] [89abAB] HEX{2} UTFPREF [dD] [c-fC-F] HEX{2} ; - + <JS>"{" { return '{'; } <JS>"}" { return '}'; } <JS>"[" { return '['; } @@ -190,7 +190,7 @@ std: if (s->limit < s->cursor) { return PHP_JSON_T_EOI; } else { - s->errcode = PHP_JSON_ERROR_SYNTAX; + s->errcode = PHP_JSON_ERROR_CTRL_CHAR; return PHP_JSON_T_ERROR; } } @@ -200,6 +200,18 @@ std: PHP_JSON_CONDITION_SET(STR_P1); PHP_JSON_CONDITION_GOTO(STR_P1); } + <JS>CTRL { + s->errcode = PHP_JSON_ERROR_CTRL_CHAR; + return PHP_JSON_T_ERROR; + } + <JS>UTF8 { + s->errcode = PHP_JSON_ERROR_SYNTAX; + return PHP_JSON_T_ERROR; + } + <JS>ANY { + s->errcode = PHP_JSON_ERROR_UTF8; + return PHP_JSON_T_ERROR; + } <STR_P1>CTRL { s->errcode = PHP_JSON_ERROR_CTRL_CHAR; |