File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) {
100100 break ;
101101 case '"' :
102102 vstr_reset (& vstr );
103- for (s ++ ; s < top && * s != '"' ; s ++ ) {
103+ for (s ++ ; s < top && * s != '"' ;) {
104104 byte c = * s ;
105105 if (c == '\\' ) {
106106 s ++ ;
@@ -111,10 +111,24 @@ STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) {
111111 case 'n' : c = 0x0a ; break ;
112112 case 'r' : c = 0x0d ; break ;
113113 case 't' : c = 0x09 ; break ;
114- case 'u' : if (s + 4 >= top ) { goto fail ; } else { assert (0 ); } //vstr_add_char(&vstr, s[0]
114+ case 'u' : {
115+ if (s + 4 >= top ) { goto fail ; }
116+ mp_uint_t num = 0 ;
117+ for (int i = 0 ; i < 4 ; i ++ ) {
118+ c = (* ++ s | 0x20 ) - '0' ;
119+ if (c > 9 ) {
120+ c -= ('a' - ('9' + 1 ));
121+ }
122+ num = (num << 4 ) | c ;
123+ }
124+ vstr_add_char (& vstr , num );
125+ goto str_cont ;
126+ }
115127 }
116128 }
117129 vstr_add_byte (& vstr , c );
130+ str_cont :
131+ s ++ ;
118132 }
119133 if (s == top ) {
120134 goto fail ;
You can’t perform that action at this time.
0 commit comments