mirror of
https://github.com/vim/vim.git
synced 2025-07-04 23:07:33 -04:00
patch 8.2.3413: Vim9: too many characters are allowed in import name
Problem: Vim9: too many characters are allowed in import name. Solution: Disallow ':' and '#', check for white space. (closes #8845)
This commit is contained in:
parent
af2d5d2ce2
commit
a9e3d56087
@ -270,8 +270,8 @@ EXTERN char e_missing_as_after_star[]
|
|||||||
INIT(= N_("E1045: Missing \"as\" after *"));
|
INIT(= N_("E1045: Missing \"as\" after *"));
|
||||||
EXTERN char e_missing_comma_in_import[]
|
EXTERN char e_missing_comma_in_import[]
|
||||||
INIT(= N_("E1046: Missing comma in import"));
|
INIT(= N_("E1046: Missing comma in import"));
|
||||||
EXTERN char e_syntax_error_in_import[]
|
EXTERN char e_syntax_error_in_import_str[]
|
||||||
INIT(= N_("E1047: Syntax error in import"));
|
INIT(= N_("E1047: Syntax error in import: %s"));
|
||||||
EXTERN char e_item_not_found_in_script_str[]
|
EXTERN char e_item_not_found_in_script_str[]
|
||||||
INIT(= N_("E1048: Item not found in script: %s"));
|
INIT(= N_("E1048: Item not found in script: %s"));
|
||||||
EXTERN char e_item_not_exported_in_script_str[]
|
EXTERN char e_item_not_exported_in_script_str[]
|
||||||
|
@ -1490,6 +1490,23 @@ def Test_import_star_fails()
|
|||||||
var that = foo
|
var that = foo
|
||||||
END
|
END
|
||||||
CheckScriptFailure(lines, 'E1029: Expected ''.''')
|
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')
|
delete('Xfoo.vim')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
@ -755,6 +755,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
3413,
|
||||||
/**/
|
/**/
|
||||||
3412,
|
3412,
|
||||||
/**/
|
/**/
|
||||||
|
@ -396,12 +396,19 @@ handle_import(
|
|||||||
arg = skipwhite_and_linebreak(arg, evalarg);
|
arg = skipwhite_and_linebreak(arg, evalarg);
|
||||||
if (STRNCMP("as", arg, 2) == 0 && IS_WHITE_OR_NUL(arg[2]))
|
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);
|
arg = skipwhite(arg + 2);
|
||||||
p = arg;
|
p = arg;
|
||||||
if (eval_isnamec1(*arg))
|
if (eval_isnamec1(*arg))
|
||||||
while (eval_isnamec(*arg))
|
while (ASCII_ISALNUM(*arg) || *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)
|
if (check_defined(p, arg - p, cctx, FALSE) == FAIL)
|
||||||
goto erret;
|
goto erret;
|
||||||
as_name = vim_strnsave(p, arg - p);
|
as_name = vim_strnsave(p, arg - p);
|
||||||
@ -439,7 +446,7 @@ handle_import(
|
|||||||
|
|
||||||
if (names.ga_len == 0)
|
if (names.ga_len == 0)
|
||||||
{
|
{
|
||||||
emsg(_(e_syntax_error_in_import));
|
semsg(_(e_syntax_error_in_import_str), arg_start);
|
||||||
goto erret;
|
goto erret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user