comparison src/spellfile.c @ 28790:a161c262e947 v8.2.4919

patch 8.2.4919: can add invalid bytes with :spellgood Commit: https://github.com/vim/vim/commit/7c824682d2028432ee082703ef0ab399867a089b Author: Bram Moolenaar <Bram@vim.org> Date: Sun May 8 22:32:58 2022 +0100 patch 8.2.4919: can add invalid bytes with :spellgood Problem: Can add invalid bytes with :spellgood. Solution: Check for a valid word string.
author Bram Moolenaar <Bram@vim.org>
date Sun, 08 May 2022 23:45:02 +0200
parents 4dcccb2673fe
children f4ff490d51a7
comparison
equal deleted inserted replaced
28789:be28873d2f74 28790:a161c262e947
4388 int ct = captype(word, word + len); 4388 int ct = captype(word, word + len);
4389 char_u foldword[MAXWLEN]; 4389 char_u foldword[MAXWLEN];
4390 int res = OK; 4390 int res = OK;
4391 char_u *p; 4391 char_u *p;
4392 4392
4393 // Avoid adding illegal bytes to the word tree.
4394 if (enc_utf8 && !utf_valid_string(word, NULL))
4395 return FAIL;
4396
4393 (void)spell_casefold(curwin, word, len, foldword, MAXWLEN); 4397 (void)spell_casefold(curwin, word, len, foldword, MAXWLEN);
4394 for (p = pfxlist; res == OK; ++p) 4398 for (p = pfxlist; res == OK; ++p)
4395 { 4399 {
4396 if (!need_affix || (p != NULL && *p != NUL)) 4400 if (!need_affix || (p != NULL && *p != NUL))
4397 res = tree_add_word(spin, foldword, spin->si_foldroot, ct | flags, 4401 res = tree_add_word(spin, foldword, spin->si_foldroot, ct | flags,
6188 char_u line[MAXWLEN * 2]; 6192 char_u line[MAXWLEN * 2];
6189 long fpos, fpos_next = 0; 6193 long fpos, fpos_next = 0;
6190 int i; 6194 int i;
6191 char_u *spf; 6195 char_u *spf;
6192 6196
6197 if (enc_utf8 && !utf_valid_string(word, NULL))
6198 {
6199 emsg(_(e_illegal_character_in_word));
6200 return;
6201 }
6202
6193 if (idx == 0) // use internal wordlist 6203 if (idx == 0) // use internal wordlist
6194 { 6204 {
6195 if (int_wordlist == NULL) 6205 if (int_wordlist == NULL)
6196 { 6206 {
6197 int_wordlist = vim_tempname('s', FALSE); 6207 int_wordlist = vim_tempname('s', FALSE);