diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-05-08 22:32:58 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-05-08 22:32:58 +0100 |
commit | 7c824682d2028432ee082703ef0ab399867a089b (patch) | |
tree | f2f5fd36e29e8aaeadb17ae0289d2a685afaafb5 /src/spellfile.c | |
parent | 9830db63057db76044eca89cc4cfb2758ae7a543 (diff) | |
download | vim-git-7c824682d2028432ee082703ef0ab399867a089b.tar.gz |
patch 8.2.4919: can add invalid bytes with :spellgoodv8.2.4919
Problem: Can add invalid bytes with :spellgood.
Solution: Check for a valid word string.
Diffstat (limited to 'src/spellfile.c')
-rw-r--r-- | src/spellfile.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/spellfile.c b/src/spellfile.c index 22cf82da0..f0d6d96a4 100644 --- a/src/spellfile.c +++ b/src/spellfile.c @@ -4390,6 +4390,10 @@ store_word( int res = OK; char_u *p; + // Avoid adding illegal bytes to the word tree. + if (enc_utf8 && !utf_valid_string(word, NULL)) + return FAIL; + (void)spell_casefold(curwin, word, len, foldword, MAXWLEN); for (p = pfxlist; res == OK; ++p) { @@ -6190,6 +6194,12 @@ spell_add_word( int i; char_u *spf; + if (enc_utf8 && !utf_valid_string(word, NULL)) + { + emsg(_(e_illegal_character_in_word)); + return; + } + if (idx == 0) // use internal wordlist { if (int_wordlist == NULL) |