From 1fe1bb084d0099fc4f9bfdc11189485d0f74b75a Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 19 Dec 2022 16:37:45 +0000 Subject: refactor(options): deprecate nvim[_buf|_win]_[gs]et_option Co-authored-by: zeertzjq Co-authored-by: famiu --- test/functional/ui/wildmode_spec.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'test/functional/ui/wildmode_spec.lua') diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua index 50466c9473..0355c57b5a 100644 --- a/test/functional/ui/wildmode_spec.lua +++ b/test/functional/ui/wildmode_spec.lua @@ -367,12 +367,12 @@ describe("'wildmenu'", function() } -- Wildcharm? where we are going we aint't no need no wildcharm. - eq(0, meths.get_option'wildcharm') + eq(0, meths.get_option_value('wildcharm', {})) -- Don't mess the defaults yet (neovim is about backwards compatibility) - eq(9, meths.get_option'wildchar') + eq(9, meths.get_option_value('wildchar', {})) -- Lol what is cnoremap? Some say it can define mappings. command 'set wildchar=0' - eq(0, meths.get_option'wildchar') + eq(0, meths.get_option_value('wildchar', {})) command 'cnoremap ' feed(':syntax ') @@ -481,9 +481,9 @@ describe('command line completion', function() end) it('does not leak memory with with wildmenu and only one match #19874', function() - meths.set_option('wildmenu', true) - meths.set_option('wildmode', 'full') - meths.set_option('wildoptions', 'pum') + meths.set_option_value('wildmenu', true, {}) + meths.set_option_value('wildmode', 'full', {}) + meths.set_option_value('wildoptions', 'pum', {}) feed(':sign unpla') screen:expect([[ @@ -505,8 +505,8 @@ describe('command line completion', function() end) it('does not show matches with without wildmenu with wildmode=full', function() - meths.set_option('wildmenu', false) - meths.set_option('wildmode', 'full') + meths.set_option_value('wildmenu', false, {}) + meths.set_option_value('wildmode', 'full', {}) feed(':sign ') screen:expect([[ @@ -519,8 +519,8 @@ describe('command line completion', function() end) it('shows matches with without wildmenu with wildmode=list', function() - meths.set_option('wildmenu', false) - meths.set_option('wildmode', 'list') + meths.set_option_value('wildmenu', false, {}) + meths.set_option_value('wildmode', 'list', {}) feed(':sign ') screen:expect([[ -- cgit From 272ef271153b0f66410b0e59ce31e05d211b44fd Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 17 Oct 2023 22:43:42 +0800 Subject: vim-patch:9.0.2035: [security] use-after-free with wildmenu (#25687) Problem: [security] use-after-free with wildmenu Solution: properly clean up the wildmenu when exiting Fix wildchar/wildmenu/pum memory corruption with special wildchar's Currently, using `wildchar=` or `wildchar=` can lead to a memory corruption if using wildmenu+pum, or wrong states if only using wildmenu. This is due to the code only using one single place inside the cmdline process loop to perform wild menu clean up (by checking `end_wildmenu`) but there are other odd situations where the loop could have exited and we need a post-loop clean up just to be sure. If the clean up was not done you would have a stale popup menu referring to invalid memory, or if not using popup menu, incorrect status line (if `laststatus=0`). For example, if you hit `` two times when it's wildchar, there's a hard-coded behavior to exit command-line as a failsafe for user, and if you hit `` it will also exit command-line, but the clean up code would not have hit because of specialized `` handling. Fix Ctrl-E / Ctrl-Y to not cancel/accept wildmenu if they are also used for 'wildchar'/'wildcharm'. Currently they don't behave properly, and also have potentially memory unsafe behavior as the logic is currently not accounting for this situation and try to do both. (Previous patch that addressed this: vim/vim#11677) Also, correctly document Escape key behavior (double-hit it to escape) in wildchar docs as it's previously undocumented. In addition, block known invalid chars to be set in `wildchar` option, such as Ctrl-C and ``. This is just to make it clear to the user they shouldn't be set, and is not required for this bug fix. closes: vim/vim#13361 https://github.com/vim/vim/commit/8f4fb007e4d472b09ff6bed9ffa485e0c3093699 Co-authored-by: Yee Cheng Chin --- test/functional/ui/wildmode_spec.lua | 79 ++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) (limited to 'test/functional/ui/wildmode_spec.lua') diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua index 0355c57b5a..3201135b67 100644 --- a/test/functional/ui/wildmode_spec.lua +++ b/test/functional/ui/wildmode_spec.lua @@ -17,6 +17,85 @@ describe("'wildmenu'", function() screen:attach() end) + -- oldtest: Test_wildmenu_screendump() + it('works', function() + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}; -- NonText + [1] = {foreground = Screen.colors.Black, background = Screen.colors.Yellow}; -- WildMenu + [2] = {bold = true, reverse = true}; -- StatusLine + }) + -- Test simple wildmenu + feed(':sign ') + screen:expect{grid=[[ + | + {0:~ }| + {0:~ }| + {1:define}{2: jump list > }| + :sign define^ | + ]]} + + feed('') + screen:expect{grid=[[ + | + {0:~ }| + {0:~ }| + {2:define }{1:jump}{2: list > }| + :sign jump^ | + ]]} + + feed('') + screen:expect{grid=[[ + | + {0:~ }| + {0:~ }| + {2:define jump }{1:list}{2: > }| + :sign list^ | + ]]} + + -- Looped back to the original value + feed('') + screen:expect{grid=[[ + | + {0:~ }| + {0:~ }| + {2:define jump list > }| + :sign ^ | + ]]} + + -- Test that the wild menu is cleared properly + feed('') + screen:expect{grid=[[ + | + {0:~ }| + {0:~ }| + {0:~ }| + :sign ^ | + ]]} + + -- Test that a different wildchar still works + feed('') + command('set wildchar=') + feed(':sign ') + screen:expect{grid=[[ + | + {0:~ }| + {0:~ }| + {1:define}{2: jump list > }| + :sign define^ | + ]]} + + -- Double- is a hard-coded method to escape while wildchar=. Make + -- sure clean up is properly done in edge case like this. + feed('') + screen:expect{grid=[[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]} + end) + it('C-E to cancel wildmenu completion restore original input', function() feed(':sign ') screen:expect([[ -- cgit