From f9a565d1e03595a6bc9e5dc9fb74f941bb741687 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Mon, 26 Jun 2017 01:28:18 +0200 Subject: [PATCH] Ignore C1 control codes C1 control codes are not used nowadays and just risks messing up the terminal when they are used by accident. --- .../main/java/com/termux/terminal/TerminalEmulator.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/terminal-emulator/src/main/java/com/termux/terminal/TerminalEmulator.java b/terminal-emulator/src/main/java/com/termux/terminal/TerminalEmulator.java index a9c88004..a993d834 100644 --- a/terminal-emulator/src/main/java/com/termux/terminal/TerminalEmulator.java +++ b/terminal-emulator/src/main/java/com/termux/terminal/TerminalEmulator.java @@ -419,10 +419,11 @@ public final class TerminalEmulator { mUtf8Index = mUtf8ToFollow = 0; if (codePoint >= 0x80 && codePoint <= 0x9F) { - // Sequence decoded to a C1 control character which is the same as escape followed by - // ((code & 0x7F) + 0x40). - processCodePoint(/* escape (hexadecimal=0x1B, octal=033): */27); - processCodePoint((codePoint & 0x7F) + 0x40); + // Sequence decoded to a C1 control character which we ignore. They are + // not used nowadays and increases the risk of messing up the terminal state + // on binary input. XTerm does not allow them in utf-8: + // "It is not possible to use a C1 control obtained from decoding the + // UTF-8 text" - http://invisible-island.net/xterm/ctlseqs/ctlseqs.html } else { switch (Character.getType(codePoint)) { case Character.UNASSIGNED: