diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-09-08 12:31:35 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-09-08 12:31:35 +0200 |
commit | a9e3d560877489acf751f99e045ab1d78e13249c (patch) | |
tree | 0b61653696b82adb6bcb97930963c3e860503288 /src/vim9script.c | |
parent | af2d5d2ce26029a47547c05be964e749bb0310d0 (diff) | |
download | vim-git-a9e3d560877489acf751f99e045ab1d78e13249c.tar.gz |
patch 8.2.3413: Vim9: too many characters are allowed in import namev8.2.3413
Problem: Vim9: too many characters are allowed in import name.
Solution: Disallow ':' and '#', check for white space. (closes #8845)
Diffstat (limited to 'src/vim9script.c')
-rw-r--r-- | src/vim9script.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/vim9script.c b/src/vim9script.c index 9ddc48930..ca245b255 100644 --- a/src/vim9script.c +++ b/src/vim9script.c @@ -396,12 +396,19 @@ handle_import( arg = skipwhite_and_linebreak(arg, evalarg); if (STRNCMP("as", arg, 2) == 0 && IS_WHITE_OR_NUL(arg[2])) { - // skip over "as Name "; no line break allowed after "as" + // Skip over "as Name "; no line break allowed after "as". + // Do not allow for ':' and '#'. arg = skipwhite(arg + 2); p = arg; if (eval_isnamec1(*arg)) - while (eval_isnamec(*arg)) + while (ASCII_ISALNUM(*arg) || *arg == '_') ++arg; + if (p == arg || !(IS_WHITE_OR_NUL(*arg) + || (mult && (*arg == ',' || *arg == '}')))) + { + semsg(_(e_syntax_error_in_import_str), p); + goto erret; + } if (check_defined(p, arg - p, cctx, FALSE) == FAIL) goto erret; as_name = vim_strnsave(p, arg - p); @@ -439,7 +446,7 @@ handle_import( if (names.ga_len == 0) { - emsg(_(e_syntax_error_in_import)); + semsg(_(e_syntax_error_in_import_str), arg_start); goto erret; } |