Blame SOURCES/irssi-1.2.2-ctrl-space-fix.patch

4646b5
From a0544571a80196e5b7705f56e6e2cbcdf7b4d80e Mon Sep 17 00:00:00 2001
4646b5
From: ailin-nemui <ailin-nemui@users.noreply.github.com>
4646b5
Date: Thu, 23 Apr 2020 21:45:15 +0200
4646b5
Subject: [PATCH] manually handle NUL unicode in g_utf8_get_next_char_validated
4646b5
4646b5
A change in GLib 2.63 broke some assumptions in Irssi that the null-byte
4646b5
NUL / U+0000 is a valid Unicode character. This would occur when the
4646b5
user types Ctrl+Space. As a result, the input loop never manages to
4646b5
process the NUL-byte (and any other user input that follows, ever).
4646b5
4646b5
This patch adds a manual check that properly advances the input loop if
4646b5
GLib returns -2 (incomplete character) despite the length being positive
4646b5
and a NUL is in first position.
4646b5
4646b5
Fixes #1180
4646b5
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/967
4646b5
https://gitlab.gnome.org/GNOME/glib/-/issues/2093
4646b5
---
4646b5
 src/fe-text/term-terminfo.c | 6 +++++-
4646b5
 1 file changed, 5 insertions(+), 1 deletion(-)
4646b5
4646b5
diff --git a/src/fe-text/term-terminfo.c b/src/fe-text/term-terminfo.c
4646b5
index 5235f72d2..78496a64f 100644
4646b5
--- a/src/fe-text/term-terminfo.c
4646b5
+++ b/src/fe-text/term-terminfo.c
4646b5
@@ -672,7 +672,11 @@ void term_stop(void)
4646b5
 
4646b5
 static int input_utf8(const unsigned char *buffer, int size, unichar *result)
4646b5
 {
4646b5
-	unichar c = g_utf8_get_char_validated((char *)buffer, size);
4646b5
+	unichar c = g_utf8_get_char_validated((char *) buffer, size);
4646b5
+
4646b5
+	/* GLib >= 2.63 do not accept Unicode NUL anymore */
4646b5
+	if (c == (unichar) -2 && *buffer == 0 && size > 0)
4646b5
+		c = 0;
4646b5
 
4646b5
 	switch (c) {
4646b5
 	case (unichar)-1: