Patch 8.2.3413
Problem: Vim9: too many characters are allowed in import name.
Solution: Disallow ':' and '#', check for white space. (closes #8845)
Files: src/vim9script.c, src/errors.h, src/testdir/test_vim9_script.vim
*** ../vim-8.2.3412/src/vim9script.c 2021-08-15 14:39:09.164363110 +0200
--- src/vim9script.c 2021-09-08 12:30:01.654606403 +0200
***************
*** 396,407 ****
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"
arg = skipwhite(arg + 2);
p = arg;
if (eval_isnamec1(*arg))
! while (eval_isnamec(*arg))
++arg;
if (check_defined(p, arg - p, cctx, FALSE) == FAIL)
goto erret;
as_name = vim_strnsave(p, arg - p);
--- 396,414 ----
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".
! // Do not allow for ':' and '#'.
arg = skipwhite(arg + 2);
p = arg;
if (eval_isnamec1(*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,445 ****
if (names.ga_len == 0)
{
! emsg(_(e_syntax_error_in_import));
goto erret;
}
--- 446,452 ----
if (names.ga_len == 0)
{
! semsg(_(e_syntax_error_in_import_str), arg_start);
goto erret;
}
*** ../vim-8.2.3412/src/errors.h 2021-09-07 22:12:15.489452165 +0200
--- src/errors.h 2021-09-08 12:21:13.796096935 +0200
***************
*** 270,277 ****
INIT(= N_("E1045: Missing \"as\" after *"));
EXTERN char e_missing_comma_in_import[]
INIT(= N_("E1046: Missing comma in import"));
! EXTERN char e_syntax_error_in_import[]
! INIT(= N_("E1047: Syntax error in import"));
EXTERN char e_item_not_found_in_script_str[]
INIT(= N_("E1048: Item not found in script: %s"));
EXTERN char e_item_not_exported_in_script_str[]
--- 270,277 ----
INIT(= N_("E1045: Missing \"as\" after *"));
EXTERN char e_missing_comma_in_import[]
INIT(= N_("E1046: Missing comma in import"));
! EXTERN char e_syntax_error_in_import_str[]
! INIT(= N_("E1047: Syntax error in import: %s"));
EXTERN char e_item_not_found_in_script_str[]
INIT(= N_("E1048: Item not found in script: %s"));
EXTERN char e_item_not_exported_in_script_str[]
*** ../vim-8.2.3412/src/testdir/test_vim9_script.vim 2021-09-07
22:35:30.665999020 +0200
--- src/testdir/test_vim9_script.vim 2021-09-08 12:30:50.202469417 +0200
***************
*** 1490,1495 ****
--- 1490,1512 ----
var that = foo
END
CheckScriptFailure(lines, 'E1029: Expected ''.''')
+
+ lines =<< trim END
+ vim9script
+ import * as 9foo from './Xfoo.vim'
+ END
+ CheckScriptFailure(lines, 'E1047:')
+ lines =<< trim END
+ vim9script
+ import * as the#foo from './Xfoo.vim'
+ END
+ CheckScriptFailure(lines, 'E1047:')
+ lines =<< trim END
+ vim9script
+ import * as g:foo from './Xfoo.vim'
+ END
+ CheckScriptFailure(lines, 'E1047:')
+
delete('Xfoo.vim')
enddef
*** ../vim-8.2.3412/src/version.c 2021-09-07 22:35:30.665999020 +0200
--- src/version.c 2021-09-08 12:19:42.356355078 +0200
***************
*** 757,758 ****
--- 757,760 ----
{ /* Add new patch number below this line */
+ /**/
+ 3413,
/**/
--
hundred-and-one symptoms of being an internet addict:
5. You find yourself brainstorming for new subjects to search.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202109081031.188AVxme1872641%40masaka.moolenaar.net.