From: Francis De Brabandere <francisdb@gmail.com> --- dlls/vbscript/lex.c | 7 +++++-- dlls/vbscript/tests/run.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/dlls/vbscript/lex.c b/dlls/vbscript/lex.c index 1f9c4c3b18c..8e3d41ba4ed 100644 --- a/dlls/vbscript/lex.c +++ b/dlls/vbscript/lex.c @@ -102,9 +102,12 @@ static const struct { {L"xor", tXOR} }; +/* VBScript identifiers are ASCII-only: [A-Za-z0-9_]. Windows rejects all + * non-ASCII characters (Latin-1, Cyrillic, CJK) at the lexer level with + * error 1032 "Invalid character". */ static inline BOOL is_identifier_char(WCHAR c) { - return iswalnum(c) || c == '_'; + return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_'; } static int check_keyword(parser_ctx_t *ctx, const WCHAR *word, const WCHAR **lval) @@ -411,7 +414,7 @@ static int parse_next_token(void *lval, unsigned *loc, parser_ctx_t *ctx) if('0' <= c && c <= '9') return parse_numeric_literal(ctx, lval); - if(iswalpha(c)) { + if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) { int ret = 0; if(ctx->last_token != '.' && ctx->last_token != tDOT) ret = check_keywords(ctx, lval); diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c index da6f31ff4df..f1a0320d327 100644 --- a/dlls/vbscript/tests/run.c +++ b/dlls/vbscript/tests/run.c @@ -3049,6 +3049,36 @@ static void test_parse_errors(void) L"x = 1 _x\n", 0, 7, NULL, S_OK, 1032 + }, + { + /* Non-ASCII: e-acute (chr 233) in identifier */ + L"Dim caf\x00e9\n", + 0, 7, + NULL, S_OK, 1032 + }, + { + /* Non-ASCII: sharp-s (chr 223) in identifier */ + L"Dim st\x00df" L"e\n", + 0, 6, + NULL, S_OK, 1032 + }, + { + /* Non-ASCII: u-umlaut (chr 252) in identifier */ + L"Dim x\x00fc" L"b\n", + 0, 5, + NULL, S_OK, 1032 + }, + { + /* Non-ASCII: Cyrillic a (chr 1072) as identifier start */ + L"Dim \x0430\n", + 0, 4, + NULL, S_OK, 1032 + }, + { + /* Non-ASCII: e-acute (chr 233) starting identifier */ + L"\x00e9var = 1\n", + 0, 0, + NULL, S_OK, 1032 } }; HRESULT hres; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10544