]> granicus.if.org Git - php/commitdiff
Fix processing of control characters; they should be escaped as \u
authorAndrei Zmievski <andrei@php.net>
Fri, 13 Apr 2007 21:34:12 +0000 (21:34 +0000)
committerAndrei Zmievski <andrei@php.net>
Fri, 13 Apr 2007 21:34:12 +0000 (21:34 +0000)
sequences.

ext/json/JSON_parser.c
ext/json/json.c

index dce42d37eeb7c5e1554a840082bc89c1951f122c..0fbdb1add1d22d27da7d017ebd5e31961139f61b 100644 (file)
@@ -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;
index 809d005c57acc67d7c84c7fd8392147d4ec5e848..93aec133f063d92ec5dc843da417d689ee56dce9 100644 (file)
@@ -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);
                     }