mirror of
https://github.com/alacritty/alacritty
synced 2024-10-14 11:42:28 +00:00
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.
This commit is contained in:
parent
cdea958e71
commit
263a4e8a2e
21
src/ansi.rs
21
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 {
|
||||
|
|
Loading…
Reference in a new issue