summaryrefslogtreecommitdiff
path: root/ext/json
diff options
context:
space:
mode:
authorAndrei Zmievski <andrei@php.net>2007-04-13 21:34:12 +0000
committerAndrei Zmievski <andrei@php.net>2007-04-13 21:34:12 +0000
commitb62d120580edeaae4e50a63f44ef15ab460d42fc (patch)
tree5620ab0ac2f67a7c96f892bde987f5c5eb338b33 /ext/json
parentbcd72ca5a3cb37b1679b4ecce3a833c890b51ec7 (diff)
downloadphp-git-b62d120580edeaae4e50a63f44ef15ab460d42fc.tar.gz
Fix processing of control characters; they should be escaped as \u
sequences.
Diffstat (limited to 'ext/json')
-rw-r--r--ext/json/JSON_parser.c10
-rw-r--r--ext/json/json.c2
2 files changed, 10 insertions, 2 deletions
diff --git a/ext/json/JSON_parser.c b/ext/json/JSON_parser.c
index dce42d37ee..0fbdb1add1 100644
--- a/ext/json/JSON_parser.c
+++ b/ext/json/JSON_parser.c
@@ -169,7 +169,7 @@ static const int ascii_class[128] = {
accepted if the end of the text is in state 9 and mode is MODE_DONE.
*/
static const int state_transition_table[30][31] = {
-/* 0*/ { 0, 0,-8,-1,-6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
+/* 0*/ { 0, 0,-8,-1,-6,-1,-1,-1, 3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
/* 1*/ { 1, 1,-1,-9,-1,-1,-1,-1, 3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
/* 2*/ { 2, 2,-8,-1,-6,-5,-1,-1, 3,-1,-1,-1,20,-1,21,22,-1,-1,-1,-1,-1,13,-1,17,-1,-1,10,-1,-1,-1,-1},
/* 3*/ { 3,-1, 3, 3, 3, 3, 3, 3,-4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3},
@@ -577,6 +577,14 @@ JSON_parser(zval *z, unsigned short p[], int length, int assoc TSRMLS_DC)
case MODE_OBJECT:
the_state = 9;
break;
+ case MODE_DONE:
+ if (type == IS_STRING) {
+ smart_str_0(&buf);
+ ZVAL_STRINGL(z, buf.c, buf.len, 1);
+ the_state = 9;
+ break;
+ }
+ /* fall through if not IS_STRING */
default:
FREE_BUFFERS();
return false;
diff --git a/ext/json/json.c b/ext/json/json.c
index 809d005c57..93aec133f0 100644
--- a/ext/json/json.c
+++ b/ext/json/json.c
@@ -303,7 +303,7 @@ static void json_escape_string(smart_str *buf, char *s, int len)
break;
default:
{
- if (us < ' ' || (us & 127) == us)
+ if (us >= ' ' && (us & 127) == us)
{
smart_str_appendc(buf, (unsigned char) us);
}