]> granicus.if.org Git - php/commitdiff
MFB (handling of control characters)
authorAndrei Zmievski <andrei@php.net>
Mon, 16 Apr 2007 16:52:20 +0000 (16:52 +0000)
committerAndrei Zmievski <andrei@php.net>
Mon, 16 Apr 2007 16:52:20 +0000 (16:52 +0000)
ext/json/JSON_parser.c
ext/json/json.c

index d8d715c6526a56015a328001aabfcc14143b8328..4b88b9fbd526b618e094bbc1e36cc6599d47878f 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_UTF8_STRINGL(z, buf.c, buf.len, ZSTR_DUPLICATE);
+                                               the_state = 9;
+                                               break;
+                                       }
+                                       /* fall through if not IS_STRING */
                 default:
                     FREE_BUFFERS();
                     return false;
index c262511215ba7d8ec5a60f47fca62a8e0621936a..cb6f947667d29981c76e0ceca6acf3f3d24c1176 100644 (file)
@@ -307,7 +307,7 @@ static void json_escape_string(smart_str *buf, zstr s, int len, zend_uchar type)
                 break;
             default:
                 {
-                    if (us < ' ' || (us & 127) == us)
+                    if (us >= ' ' && (us & 127) == us)
                     {
                         smart_str_appendc(buf, (unsigned char) us);
                     }