From bafb53604a5b03fdc319f49d5c45f71df16038c1 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 26 Jun 2022 20:09:36 +0800 Subject: vim-patch:8.2.3484: crash when going through spell suggestions Problem: Crash when going through spell suggestions. Solution: Limit the text length for finding suggestions to the original length. Do not update buffers when exiting. (closes vim/vim#8965) https://github.com/vim/vim/commit/e275ba4fc994474155fbafe8b87a6d3b477456ba --- src/nvim/testdir/test_spell_utf8.vim | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_spell_utf8.vim b/src/nvim/testdir/test_spell_utf8.vim index 1d323df67e..1841289146 100644 --- a/src/nvim/testdir/test_spell_utf8.vim +++ b/src/nvim/testdir/test_spell_utf8.vim @@ -768,6 +768,21 @@ func Test_spellfile_value() set spellfile=Xdir/Xtest.utf-8.add,Xtest_other.add endfunc +func Test_no_crash_with_weird_text() + new + let lines =<< trim END + r + € + + + € + END + call setline(1, lines) + exe "%norm \ez=>\wzG" + + bwipe! +endfunc + " Invalid bytes may cause trouble when creating the word list. func Test_check_for_valid_word() call assert_fails("spellgood! 0\xac", 'E1280:') -- cgit From 80af2c6055cbc393ee73a8a38cef1e498aaae41d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 23 May 2022 19:17:09 +0800 Subject: vim-patch:8.2.5007: spell suggestion may use uninitialized memory Problem: Spell suggestion may use uninitialized memory. (Zdenek Dohnal) Solution: Avoid going over the end of the word. https://github.com/vim/vim/commit/6d24b4ff69913270ce1e5267dd6bd8454f75e2b9 --- src/nvim/testdir/test_spell_utf8.vim | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_spell_utf8.vim b/src/nvim/testdir/test_spell_utf8.vim index 1841289146..8cd2149ba1 100644 --- a/src/nvim/testdir/test_spell_utf8.vim +++ b/src/nvim/testdir/test_spell_utf8.vim @@ -631,7 +631,7 @@ func Test_spell_affix() \ ["bar", "barbork", "end", "fooa1", "fooa\u00E9", "nouend", "prebar", "prebarbork", "start"], \ [ \ ["bad", ["bar", "end", "fooa1"]], - \ ["foo", ["fooa1", "fooa\u00E9", "bar"]], + \ ["foo", ["fooa1", "bar", "end"]], \ ["fooa2", ["fooa1", "fooa\u00E9", "bar"]], \ ["prabar", ["prebar", "bar", "bar bar"]], \ ["probarbirk", ["prebarbork"]], @@ -649,7 +649,7 @@ func Test_spell_affix() \ ["bar", "barbork", "end", "lead", "meea1", "meea\u00E9", "prebar", "prebarbork"], \ [ \ ["bad", ["bar", "end", "lead"]], - \ ["mee", ["meea1", "meea\u00E9", "bar"]], + \ ["mee", ["meea1", "bar", "end"]], \ ["meea2", ["meea1", "meea\u00E9", "lead"]], \ ["prabar", ["prebar", "bar", "leadbar"]], \ ["probarbirk", ["prebarbork"]], @@ -666,7 +666,7 @@ func Test_spell_affix() \ ["bar", "barmeat", "lead", "meea1", "meea\u00E9", "meezero", "prebar", "prebarmeat", "tail"], \ [ \ ["bad", ["bar", "lead", "tail"]], - \ ["mee", ["meea1", "meea\u00E9", "bar"]], + \ ["mee", ["meea1", "bar", "lead"]], \ ["meea2", ["meea1", "meea\u00E9", "lead"]], \ ["prabar", ["prebar", "bar", "leadbar"]], \ ["probarmaat", ["prebarmeat"]], @@ -761,11 +761,15 @@ func Test_spell_sal_and_addition() set spl=Xtest_ca.utf-8.spl call assert_equal("elequint", FirstSpellWord()) call assert_equal("elekwint", SecondSpellWord()) + + set spellfile= + set spl& endfunc func Test_spellfile_value() set spellfile=Xdir/Xtest.utf-8.add set spellfile=Xdir/Xtest.utf-8.add,Xtest_other.add + set spellfile= endfunc func Test_no_crash_with_weird_text() @@ -788,5 +792,18 @@ func Test_check_for_valid_word() call assert_fails("spellgood! 0\xac", 'E1280:') endfunc +" This was going over the end of the word +func Test_word_index() + new + norm R0 + spellgood! fl0 + sil norm z= + + bwipe! + " clear the word list + set enc=utf-8 + call delete('Xtmpfile') +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From f0d4007f620d0d1aa9f0f051d83030112c4c66f1 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 18 Jun 2022 21:12:14 +0800 Subject: vim-patch:8.2.5123: using invalid index when looking for spell suggestions Problem: Using invalid index when looking for spell suggestions. Solution: Do not decrement the index when it is zero. https://github.com/vim/vim/commit/156d3911952d73b03d7420dc3540215247db0fe8 --- src/nvim/testdir/test_spell.vim | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_spell.vim b/src/nvim/testdir/test_spell.vim index ce21b8bdc9..215d4387d6 100644 --- a/src/nvim/testdir/test_spell.vim +++ b/src/nvim/testdir/test_spell.vim @@ -72,6 +72,16 @@ func Test_z_equal_on_invalid_utf8_word() bwipe! endfunc +func Test_z_equal_on_single_character() + " this was decrementing the index below zero + new + norm a0\Ê + norm zW + norm z= + + bwipe! +endfunc + " Test spellbadword() with argument func Test_spellbadword() set spell -- cgit From 6711d001c59a0b5f6cf3f5d53d837d41f1ec78a5 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 26 Jun 2022 21:18:56 +0800 Subject: fix(spell): make setting 'encoding' clear word list --- src/nvim/testdir/test_spell_utf8.vim | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_spell_utf8.vim b/src/nvim/testdir/test_spell_utf8.vim index 8cd2149ba1..3c07e0782b 100644 --- a/src/nvim/testdir/test_spell_utf8.vim +++ b/src/nvim/testdir/test_spell_utf8.vim @@ -576,7 +576,6 @@ endfunc "Compound words func Test_spell_compound() - throw 'skipped: TODO: ' call LoadAffAndDic(g:test_data_aff3, g:test_data_dic3) call RunGoodBad("foo m\u00EF foobar foofoobar barfoo barbarfoo", \ "bad: bar la foom\u00EF barm\u00EF m\u00EFfoo m\u00EFbar m\u00EFm\u00EF lala m\u00EFla lam\u00EF foola labar", @@ -624,7 +623,7 @@ endfunc " Test affix flags with two characters func Test_spell_affix() - throw 'skipped: TODO: ' + CheckNotMSWindows " FIXME: Why does this fail with MSVC? call LoadAffAndDic(g:test_data_aff5, g:test_data_dic5) call RunGoodBad("fooa1 fooa\u00E9 bar prebar barbork prebarbork startprebar start end startend startmiddleend nouend", \ "bad: foo fooa2 prabar probarbirk middle startmiddle middleend endstart startprobar startnouend", @@ -700,7 +699,6 @@ endfunc " Affix flags func Test_spell_affix_flags() - throw 'skipped: TODO: ' call LoadAffAndDic(g:test_data_aff10, g:test_data_dic10) call RunGoodBad("drink drinkable drinkables drinktable drinkabletable", \ "bad: drinks drinkstable drinkablestable", -- cgit