Finding only valid UTF-8 byte sequences when searching.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5316 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Benno Schulenberg 2015-07-23 19:18:25 +00:00
parent f47813eefa
commit b967368d41
2 changed files with 7 additions and 3 deletions

View File

@ -2,6 +2,8 @@
* doc/man/{nano.1,nanorc.5}, doc/texinfo/nano.texi: Add deprecation
notices for the options 'set const', 'set poslog' and '--poslog'.
Suggested by Eitan Adler.
* src/chars.c (mbstrcasestr, mbrevstrcasestr): When searching, find
only valid UTF-8 byte sequences. This fixes Savannah bug #45579.
2015-07-22 Mike Frysinger <vapier@gentoo.org>
* src/files.c (check_dotnano), src/global.c (thanks_for_all_the_fish),

View File

@ -636,7 +636,8 @@ char *mbstrcasestr(const char *haystack, const char *needle)
for (; *haystack != '\0' && haystack_len >= needle_len;
haystack += move_mbright(haystack, 0), haystack_len--) {
if (mbstrncasecmp(haystack, needle, needle_len) == 0)
if (mbstrncasecmp(haystack, needle, needle_len) == 0 &&
mblen(haystack, MB_CUR_MAX) > 0)
return (char *)haystack;
}
@ -729,8 +730,9 @@ char *mbrevstrcasestr(const char *haystack, const char *needle, const
rev_start_len = mbstrlen(rev_start);
while (!begin_line) {
if (rev_start_len >= needle_len && mbstrncasecmp(rev_start,
needle, needle_len) == 0)
if (rev_start_len >= needle_len &&
mbstrncasecmp(rev_start, needle, needle_len) == 0 &&
mblen(rev_start, MB_CUR_MAX) > 0)
return (char *)rev_start;
if (rev_start == haystack)