verbatim: show an error message when an invalid Unicode code is entered

The codes from (for example) U+D800 to U+DFFF are invalid.  If any
such invalid code is entered at the Unicode Input prompt, nano should
not act as if the code was accepted and inserted into the buffer, and
should certainly not mark the buffer as Modified.

This fixes https://savannah.gnu.org/bugs/?58714.

Bug existed since version 4.9, commit b3faf353.
This commit is contained in:
Benno Schulenberg 2020-07-06 16:28:11 +02:00
parent a2fdf6c486
commit 5899181a31
2 changed files with 7 additions and 1 deletions

View File

@ -200,7 +200,10 @@ void do_statusbar_verbatim_input(void)
bytes = get_verbatim_kbinput(bottomwin, &count);
inject_into_answer(bytes, count);
if (count > 0)
inject_into_answer(bytes, count);
else
beep();
free(bytes);
}

View File

@ -3016,6 +3016,7 @@ void do_verbatim_input(void)
/* Read in the first one or two bytes of the next keystroke. */
bytes = get_verbatim_kbinput(edit, &count);
if (count > 0) {
/* Unsuppress cursor-position display or blank the status bar. */
if (ISSET(CONSTANT_SHOW))
lastmessage = VACUUM;
@ -3024,6 +3025,8 @@ void do_verbatim_input(void)
/* Insert the bytes into the edit buffer. */
inject(bytes, count);
} else
statusline(ALERT, _("Invalid code"));
free(bytes);
}