From db506d991d80eb12016564eb62b5f636e7c8c836 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 9 May 2022 19:19:07 +0800 Subject: vim-patch:8.2.4924: maparg() may return a string that cannot be reused Problem: maparg() may return a string that cannot be reused. Solution: use msg_outtrans_special() instead of str2special(). (closes vim/vim#10384) https://github.com/vim/vim/commit/0519ce00394474055bd58c089ea90a19986443eb --- src/nvim/testdir/test_maparg.vim | 14 ++++++++++++++ src/nvim/testdir/test_mapping.vim | 7 +++++++ src/nvim/testdir/test_options.vim | 20 ++++++++++++++++++++ 3 files changed, 41 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_maparg.vim b/src/nvim/testdir/test_maparg.vim index cebde89996..f9429a8020 100644 --- a/src/nvim/testdir/test_maparg.vim +++ b/src/nvim/testdir/test_maparg.vim @@ -42,6 +42,20 @@ function Test_maparg() map abc yy call assert_equal("yRy", maparg('abc')) + " character with K_SPECIAL byte + nmap abc … + call assert_equal('…', maparg('abc')) + + " modified character with K_SPECIAL byte + nmap abc + call assert_equal('', maparg('abc')) + + " illegal bytes + let str = ":\x7f:\x80:\x90:\xd0:" + exe 'nmap abc ' .. str + call assert_equal(str, maparg('abc')) + unlet str + omap { w let d = maparg('{', 'o', 0, 1) call assert_equal(['{', 'w', 'o'], [d.lhs, d.rhs, d.mode]) diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim index b5158295b4..995511cddf 100644 --- a/src/nvim/testdir/test_mapping.vim +++ b/src/nvim/testdir/test_mapping.vim @@ -488,6 +488,13 @@ func Test_list_mappings() call assert_equal(['n foo'], \ execute('nmap ')->trim()->split("\n")) + " illegal bytes + let str = ":\x7f:\x80:\x90:\xd0:" + exe 'nmap foo ' .. str + call assert_equal(['n foo ' .. strtrans(str)], + \ execute('nmap foo')->trim()->split("\n")) + unlet str + " map to CTRL-V exe "nmap ,k \" call assert_equal(['n ,k '], diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim index d16d89ec2e..8f67b1732e 100644 --- a/src/nvim/testdir/test_options.vim +++ b/src/nvim/testdir/test_options.vim @@ -31,6 +31,26 @@ func Test_isfname() set isfname& endfunc +" Test for getting the value of 'pastetoggle' +func Test_pastetoggle() + " character with K_SPECIAL byte + let &pastetoggle = '…' + call assert_equal('…', &pastetoggle) + call assert_equal("\n pastetoggle=…", execute('set pastetoggle?')) + + " modified character with K_SPECIAL byte + let &pastetoggle = '' + call assert_equal('', &pastetoggle) + call assert_equal("\n pastetoggle=", execute('set pastetoggle?')) + + " illegal bytes + let str = ":\x7f:\x80:\x90:\xd0:" + let &pastetoggle = str + call assert_equal(str, &pastetoggle) + call assert_equal("\n pastetoggle=" .. strtrans(str), execute('set pastetoggle?')) + unlet str +endfunc + func Test_wildchar() " Empty 'wildchar' used to access invalid memory. call assert_fails('set wildchar=', 'E521:') -- cgit