File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed 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) {
100
100
break ;
101
101
case '"' :
102
102
vstr_reset (& vstr );
103
- for (s ++ ; s < top && * s != '"' ; s ++ ) {
103
+ for (s ++ ; s < top && * s != '"' ;) {
104
104
byte c = * s ;
105
105
if (c == '\\' ) {
106
106
s ++ ;
@@ -111,10 +111,24 @@ STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) {
111
111
case 'n' : c = 0x0a ; break ;
112
112
case 'r' : c = 0x0d ; break ;
113
113
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
+ }
115
127
}
116
128
}
117
129
vstr_add_byte (& vstr , c );
130
+ str_cont :
131
+ s ++ ;
118
132
}
119
133
if (s == top ) {
120
134
goto fail ;
You can’t perform that action at this time.
0 commit comments