mirror of
https://github.com/radareorg/quickjs.git
synced 2026-11-07 06:25:57 -10:00
Fix JS_DetectModule if the first statement is an await
This commit is contained in:
1 parent
902cc2cf0e
commit
6dd2ce308a
4 files changed
+18
-2
No files matched your search
@@ -218,6 +218,7 @@ jobs:
|
||||
build\${{matrix.buildType}}\qjs.exe tests\test_std.js
|
||||
build\${{matrix.buildType}}\qjs.exe tests\test_worker.js
|
||||
build\${{matrix.buildType}}\qjs.exe tests\test_queue_microtask.js
|
||||
build\${{matrix.buildType}}\qjs.exe tests\test_module_detect.js
|
||||
build\${{matrix.buildType}}\function_source.exe
|
||||
|
||||
windows-clang:
|
||||
@@ -253,6 +254,7 @@ jobs:
|
||||
build\${{matrix.buildType}}\qjs.exe tests\test_std.js
|
||||
build\${{matrix.buildType}}\qjs.exe tests\test_worker.js
|
||||
build\${{matrix.buildType}}\qjs.exe tests\test_queue_microtask.js
|
||||
build\${{matrix.buildType}}\qjs.exe tests\test_module_detect.js
|
||||
build\${{matrix.buildType}}\function_source.exe
|
||||
|
||||
windows-ninja:
|
||||
@@ -292,6 +294,7 @@ jobs:
|
||||
build\qjs.exe tests\test_std.js
|
||||
build\qjs.exe tests\test_worker.js
|
||||
build\qjs.exe tests\test_queue_microtask.js
|
||||
build\qjs.exe tests\test_module_detect.js
|
||||
build\function_source.exe
|
||||
|
||||
windows-mingw:
|
||||
|
||||
@@ -88,6 +88,7 @@ test: $(QJS)
|
||||
$(QJS) tests/test_std.js
|
||||
$(QJS) tests/test_worker.js
|
||||
$(QJS) tests/test_queue_microtask.js
|
||||
$(QJS) tests/test_module_detect.js
|
||||
|
||||
testconv: $(BUILD_DIR)/test_conv
|
||||
$(BUILD_DIR)/test_conv
|
||||
|
||||
@@ -20007,6 +20007,9 @@ static int simple_next_token(const uint8_t **pp, BOOL no_line_terminator)
|
||||
p[2] == 'c' && p[3] == 't' && p[4] == 'i' &&
|
||||
p[5] == 'o' && p[6] == 'n' && !lre_js_is_ident_next(p[7])) {
|
||||
return TOK_FUNCTION;
|
||||
} else if (c == 'a' && p[0] == 'w' && p[1] == 'a' &&
|
||||
p[2] == 'i' && p[3] == 't' && !lre_js_is_ident_next(p[4])) {
|
||||
return TOK_AWAIT;
|
||||
}
|
||||
return TOK_IDENT;
|
||||
}
|
||||
@@ -20048,8 +20051,11 @@ static void skip_shebang(const uint8_t **pp, const uint8_t *buf_end)
|
||||
/* return true if 'input' contains the source of a module
|
||||
(heuristic). 'input' must be a zero terminated.
|
||||
|
||||
Heuristic: skip comments and expect 'import' keyword not followed
|
||||
by '(' or '.' or export keyword.
|
||||
Heuristic:
|
||||
- Skip comments
|
||||
- Expect 'import' keyword not followed by '(' or '.'
|
||||
- Expect 'export' keyword
|
||||
- Expect 'await' keyword
|
||||
*/
|
||||
/* input is pure ASCII or UTF-8 encoded source code */
|
||||
BOOL JS_DetectModule(const char *input, size_t input_len)
|
||||
@@ -20062,6 +20068,7 @@ BOOL JS_DetectModule(const char *input, size_t input_len)
|
||||
case TOK_IMPORT:
|
||||
tok = simple_next_token(&p, FALSE);
|
||||
return (tok != '.' && tok != '(');
|
||||
case TOK_AWAIT:
|
||||
case TOK_EXPORT:
|
||||
return TRUE;
|
||||
default:
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// This needs to be parsed as a module or will throw SyntaxError.
|
||||
//
|
||||
|
||||
await 0;
|
||||
|
||||
Reference in new issue
Block a user