curses: filter unicode chars > 0xffff
authorborg323 <4010067-borg323@users.noreply.gitlab.com>
Fri, 5 Jul 2019 22:33:58 +0000 (01:33 +0300)
committerborg323 <4010067-borg323@users.noreply.gitlab.com>
Fri, 5 Jul 2019 22:33:58 +0000 (01:33 +0300)
src/curses/ux_input.c

index 774a0bdca32eb99f9e4eae04bdf2ea023b5bbcee..9a23891dfe15ab019529dd52460dec6fd66f8fb8 100644 (file)
@@ -239,8 +239,10 @@ static int unix_read_char(int extkeys)
 
        /* ...and the other 2% makes up 98% of the code. :( */
 #ifdef USE_UTF8
-    if (sel != KEY_CODE_YES && c >= ZC_LATIN1_MIN)
+    if (sel != KEY_CODE_YES && c >= ZC_LATIN1_MIN) {
+        if (c > 0xffff) continue;
         return c;
+    }
 #endif
 
        /* On many terminals the backspace key returns DEL. */
@@ -926,11 +928,14 @@ char *os_read_file_name (const char *default_name, int flag)
                    z = default_name[i++] & 0x1f;
                    z = (z << 6) | (default_name[i++] & 0x3f);
                    print_char(z);
-               } else {
+               } else if((default_name[i] & 0xf0) == 0xe0 ) {
                    z = default_name[i++] & 0xf;
                    z = (z << 6) | (default_name[i++] & 0x3f);
                    z = (z << 6) | (default_name[i++] & 0x3f);
                    print_char(z);
+               } else {
+                   i+=4;
+                   print_char('?');
                }
            }
        }