File tree Expand file tree Collapse file tree 3 files changed +26
-8
lines changed Expand file tree Collapse file tree 3 files changed +26
-8
lines changed Original file line number Diff line number Diff line change 128
128
'type-refining-gufa-exact.wast' ,
129
129
# TODO: fuzzer support for custom descriptors
130
130
'custom-descriptors.wast' ,
131
+ # TODO: fix split_wast() on tricky escaping situations like a string ending
132
+ # in \\" (the " is not escaped - there is an escaped \ before it)
133
+ 'string-lifting-section.wast' ,
131
134
]
132
135
133
136
Original file line number Diff line number Diff line change @@ -282,14 +282,20 @@ struct Value {
282
282
skip ();
283
283
if (*curr == ' "' ) {
284
284
// String
285
- // Start |close| at the opening ", and in the loop below we will always
285
+ // Start |close| after the opening ", and in the loop below we will always
286
286
// begin looking at the first character after.
287
- char * close = curr;
288
- // Skip escaped "
289
- do {
290
- close = strchr (close + 1 , ' "' );
291
- } while (*(close - 1 ) == ' \\ ' );
292
- THROW_IF (!close, " malformed JSON string" );
287
+ char * close = curr + 1 ;
288
+ // Skip escaped ", which appears as \". We need to be careful though, as
289
+ // \" might also be \\" which would be an escaped \ and an *un*escaped ".
290
+ while (*close && *close != ' "' ) {
291
+ if (*close == ' \\ ' ) {
292
+ // Skip the \ and the character after it, which it escapes.
293
+ close++;
294
+ THROW_IF (!*close, " unexpected end of JSON string (quoting)" );
295
+ }
296
+ close++;
297
+ }
298
+ THROW_IF (!close, " unexpected end of JSON string" );
293
299
*close = 0 ; // end this string, and reuse it straight from the input
294
300
char * raw = curr + 1 ;
295
301
if (stringEncoding == ASCII) {
Original file line number Diff line number Diff line change 2
2
3
3
;; Lower first to generate the string.consts custom section, then lift it back.
4
4
5
- ;; RUN: foreach %s %t wasm-opt -all --string-lowering --string-lifting -S -o - | filecheck %s
5
+ ;; RUN: wasm-opt %s -all --string-lowering --string-lifting -S -o - | filecheck %s
6
6
7
7
(module
8
8
;; CHECK: (type $0 (array (mut i16)))
37
37
38
38
;; CHECK: (import "string.const" "5" (global $"string.const_\"unpaired low surrogate \\ed\\bd\\88 \"" (ref extern)))
39
39
40
+ ;; CHECK: (import "string.const" "6" (global $"string.const_\"z\\\\\"" (ref extern)))
41
+
40
42
;; CHECK: (import "wasm:js-string" "fromCharCodeArray" (func $fromCharCodeArray (type $3) (param (ref null $0) i32 i32) (result (ref extern))))
41
43
42
44
;; CHECK: (import "wasm:js-string" "fromCodePoint" (func $fromCodePoint (type $4) (param i32) (result (ref extern))))
94
96
;; CHECK-NEXT: (drop
95
97
;; CHECK-NEXT: (string.const "unpaired low surrogate \ed\bd\88 ")
96
98
;; CHECK-NEXT: )
99
+ ;; CHECK-NEXT: (drop
100
+ ;; CHECK-NEXT: (string.const "z\\")
101
+ ;; CHECK-NEXT: )
97
102
;; CHECK-NEXT: )
98
103
(func $tricky-consts
99
104
;; These tricky strings should remain exactly the same after lowering and
110
115
(drop
111
116
(string.const " unpaired low surrogate \ED\BD\88 " )
112
117
)
118
+ ;; A string with \", but the " is not escaped, as the \ is part of \\.
119
+ (drop
120
+ (string.const " z\\ " )
121
+ )
113
122
)
114
123
)
115
124
You can’t perform that action at this time.
0 commit comments