Mercurial > vim
annotate src/testdir/test_ins_complete_no_halt.vim @ 33664:06b59278bfcf v9.0.2070
patch 9.0.2070: [security] disallow setting env in restricted mode
Commit: https://github.com/vim/vim/commit/6b89dd6a7257a1e2e9c7ea070b407bc4674a5118
Author: Christian Brabandt <cb@256bit.org>
Date: Thu Oct 26 22:14:17 2023 +0200
patch 9.0.2070: [security] disallow setting env in restricted mode
Problem: [security] disallow setting env in restricted mode
Solution: Setting environment variables in restricted mode could
potentially be used to execute shell commands. Disallow this.
restricted mode: disable allow setting of environment variables
Setting environment variables in restricted mode, may have some unwanted
consequences. So, for example by setting $GCONV_PATH in restricted mode
and then calling the iconv() function, one may be able to execute some
unwanted payload, because the `iconv_open()` function internally uses
the `$GCONV_PATH` variable to find its conversion data.
So let's disable setting environment variables, even so this is no
complete protection, since we are not clearing the existing environment.
I tried a few ways but wasn't successful :(
One could also argue to disable the iconv() function completely in
restricted mode, but who knows what other API functions can be
influenced by setting some other unrelated environment variables.
So let's leave it as it is currently.
closes: #13394
See: https://huntr.com/bounties/b0a2eda1-459c-4e36-98e6-0cc7d7faccfe/
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 26 Oct 2023 22:30:03 +0200 |
parents | b9e8c9ed792b |
children |
rev | line source |
---|---|
25513
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 " Test insert mode completion does not get stuck when looping around. |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 " In a separate file to avoid the settings to leak to other test cases. |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 set complete+=kspell |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 set completeopt+=menu |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 set completeopt+=menuone |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 set completeopt+=noselect |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 set completeopt+=noinsert |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 let g:autocompletion = v:true |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 func Test_ins_complete_no_halt() |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 function! OpenCompletion() |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 if pumvisible() && (g:autocompletion == v:true) |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 call feedkeys("\<C-e>\<C-n>", "i") |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 return |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 endif |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 if ((v:char >= 'a' && v:char <= 'z') || (v:char >= 'A' && v:char <= 'Z')) && (g:autocompletion == v:true) |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 call feedkeys("\<C-n>", "i") |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 redraw |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 endif |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 endfunction |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 autocmd InsertCharPre * noautocmd call OpenCompletion() |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
25 setlocal spell! spelllang=en_us |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
26 |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
27 call feedkeys("iauto-complete-halt-test test test test test test test test test test test test test test test test test test test\<C-c>", "tx!") |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
28 call assert_equal(["auto-complete-halt-test test test test test test test test test test test test test test test test test test test"], getline(1, "$")) |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 endfunc |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
30 |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 func Test_auto_complete_backwards_no_halt() |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 function! OpenCompletion() |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
33 if pumvisible() && (g:autocompletion == v:true) |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 call feedkeys("\<C-e>\<C-p>", "i") |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
35 return |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 endif |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 if ((v:char >= 'a' && v:char <= 'z') || (v:char >= 'A' && v:char <= 'Z')) && (g:autocompletion == v:true) |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 call feedkeys("\<C-p>", "i") |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 redraw |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 endif |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
41 endfunction |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 autocmd InsertCharPre * noautocmd call OpenCompletion() |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 setlocal spell! spelllang=en_us |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 call feedkeys("iauto-complete-halt-test test test test test test test test test test test test test test test test test test test\<C-c>", "tx!") |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 call assert_equal(["auto-complete-halt-test test test test test test test test test test test test test test test test test test test"], getline(1, "$")) |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 endfunc |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 |
b9e8c9ed792b
patch 8.2.3293: finding completions may cause an endless loop
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
51 " vim: shiftwidth=2 sts=2 expandtab |