Problem: Vim9: Can set environment variables in restricted mode
Solution: Disallow settings variables in exec_instructions() when in
restricted mode (pyllyukko)
related: #13394
closes: #19705
Signed-off-by: pyllyukko <pyllyukko@maimed.org>
Signed-off-by: Christian Brabandt <cb@256bit.org>
call delete('Xresult')
endfunc
+func Test_restricted_vim9_env()
+ let lines =<< trim END
+ vim9script
+ def SetEnv()
+ $ENV = '123'
+ enddef
+ var result = 'okay'
+ try
+ SetEnv()
+ catch /^Vim\%((\S\+)\)\=:E145:/
+ result = 'not-allowed'
+ endtry
+ writefile([result], 'XResult_env')
+ qa!
+ END
+ call writefile(lines, 'Xrestrictedvim9', 'D')
+ if RunVim([], [], '-Z --clean -S Xrestrictedvim9')
+ call assert_equal(['not-allowed'], readfile('XResult_env'))
+ endif
+ call delete('XResult_env')
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 177,
/**/
176,
/**/
// store $ENV
case ISN_STOREENV:
+ if (check_restricted())
+ goto theend;
--ectx->ec_stack.ga_len;
tv = STACK_TV_BOT(0);
vim_setenv_ext(iptr->isn_arg.string, tv_get_string(tv));