diff options
author | Joe Wilm <joe@jwilm.com> | 2016-06-06 17:41:03 -0700 |
---|---|---|
committer | Joe Wilm <joe@jwilm.com> | 2016-06-06 17:41:03 -0700 |
commit | 263a4e8a2e835d9bd5a6410b724ff05aa04de643 (patch) | |
tree | c43590b5d3fd72ca24e571e2b325c99107881e56 /src/ansi.rs | |
parent | cdea958e71fd59c8d2051feb4631badd6891e751 (diff) | |
download | alacritty-263a4e8a2e835d9bd5a6410b724ff05aa04de643.tar.gz alacritty-263a4e8a2e835d9bd5a6410b724ff05aa04de643.zip |
Fix escape bytes as input bug in ANSI parser
There were several unrecognized escape codes that have arguments which
were being interpretted as input. Naturally, this caused state to be
corrupt. The escape codes are now handled by throwing away the bytes.
Consider this a TODO for later.
Diffstat (limited to 'src/ansi.rs')
-rw-r--r-- | src/ansi.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/ansi.rs b/src/ansi.rs index cd61c6d5..e3d0f7bf 100644 --- a/src/ansi.rs +++ b/src/ansi.rs @@ -421,6 +421,9 @@ impl Parser { }, State::Csi => { self.csi(handler, c); + }, + State::EscapeOther => { + self.other(handler, c); } } } @@ -431,6 +434,18 @@ impl Parser { handler.input(c); } + fn other<H>(&mut self, handler: &mut H, c: char) + where H: Handler + { + if c == 0x07 as char || c == 0x18 as char || c == 0x1a as char || + c == 0x1b as char || is_control_c1(c) + { + self.state = State::Base; + } + + // TODO actually use these bytes. For now, we just throw them away. + } + /// Handle character following an ESC /// /// TODO Handle `ST`, `'#'`, `'P'`, `'_'`, `'^'`, `']'`, `'k'`, @@ -458,6 +473,9 @@ impl Parser { 'c' => sequence_complete!(reset_state), '7' => sequence_complete!(save_cursor_position), '8' => sequence_complete!(restore_cursor_position), + 'P' | '_' | '^' | ']' | 'k' | '(' => { + self.state = State::EscapeOther; + }, _ => { self.state = State::Base; err_println!("Unknown ESC 0x{:02x} {:?}", c as usize, c); @@ -1042,6 +1060,9 @@ enum State { /// Parsing a CSI escape, Csi, + + /// Parsing non csi escape + EscapeOther, } impl Default for State { |