aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoe Wilm <joe@jwilm.com>2017-03-01 22:03:35 -0800
committerJoe Wilm <joe@jwilm.com>2017-03-01 22:03:35 -0800
commit3b70b0d5953e8510d556e96cfb32f288d35dd705 (patch)
tree8c1a9551bad96d0ae783a12086331e54806125d1 /src
parent8c7fb776df288cf189fca60e211c5dd3a5c9241a (diff)
downloadr-alacritty-vte-3b70b0d5953e8510d556e96cfb32f288d35dd705.tar.gz
r-alacritty-vte-3b70b0d5953e8510d556e96cfb32f288d35dd705.tar.bz2
r-alacritty-vte-3b70b0d5953e8510d556e96cfb32f288d35dd705.zip
Fix bug in OSC parsing and drop 8-bit code support
OSC parsing now handles UTF-8 arguments. 8-bit code support was dropped to make supporting this easier.
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs33
-rw-r--r--src/table.rs32
-rw-r--r--src/table.rs.in14
3 files changed, 48 insertions, 31 deletions
diff --git a/src/lib.rs b/src/lib.rs
index a697b17..68eb9e4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -24,6 +24,8 @@
//!
//! * UTF-8 Support for Input
//! * OSC Strings can be terminated by 0x07
+//! * Only supports 7-bit codes. Some 8-bit codes are still supported, but they
+//! no longer work in all states.
//!
//! [`Parser`]: struct.Parser.html
//! [`Perform`]: trait.Perform.html
@@ -408,7 +410,7 @@ pub trait Perform {
mod tests {
use super::{Parser, Perform};
- static OSC_BYTES: &'static [u8] = &[0x9d, // Begin OSC
+ static OSC_BYTES: &'static [u8] = &[0x1b, 0x5d, // Begin OSC
b'2', b';', b'j', b'w', b'i', b'l', b'm', b'@', b'j', b'w', b'i', b'l',
b'm', b'-', b'd', b'e', b's', b'k', b':', b' ', b'~', b'/', b'c', b'o',
b'd', b'e', b'/', b'a', b'l', b'a', b'c', b'r', b'i', b't', b't', b'y',
@@ -452,8 +454,8 @@ mod tests {
// Check that flag is set and thus osc_dispatch assertions ran.
assert!(dispatcher.dispatched_osc);
assert_eq!(dispatcher.params.len(), 2);
- assert_eq!(dispatcher.params[0], &OSC_BYTES[1..2]);
- assert_eq!(dispatcher.params[1], &OSC_BYTES[3..(OSC_BYTES.len() - 1)]);
+ assert_eq!(dispatcher.params[0], &OSC_BYTES[2..3]);
+ assert_eq!(dispatcher.params[1], &OSC_BYTES[4..(OSC_BYTES.len() - 1)]);
}
#[test]
@@ -464,7 +466,7 @@ mod tests {
// Run parser using OSC_BYTES
let mut parser = Parser::new();
- for byte in &[0x9d, 0x07] {
+ for byte in &[0x1b, 0x5d, 0x07] {
parser.advance(&mut dispatcher, *byte);
}
@@ -503,4 +505,27 @@ mod tests {
// Check that flag is set and thus osc_dispatch assertions ran.
assert_eq!(dispatcher.params[0], &[0, 4]);
}
+
+ #[test]
+ fn parse_osc_with_utf8_arguments() {
+ static INPUT: &'static [u8] = &[
+ 0x0d, 0x1b, 0x5d, 0x32, 0x3b, 0x65, 0x63, 0x68, 0x6f, 0x20, 0x27,
+ 0xc2, 0xaf, 0x5c, 0x5f, 0x28, 0xe3, 0x83, 0x84, 0x29, 0x5f, 0x2f,
+ 0xc2, 0xaf, 0x27, 0x20, 0x26, 0x26, 0x20, 0x73, 0x6c, 0x65, 0x65,
+ 0x70, 0x20, 0x31, 0x07
+ ];
+
+ // Create dispatcher and check state
+ let mut dispatcher = OscDispatcher { params: vec![], dispatched_osc: false };
+
+ // Run parser using OSC_BYTES
+ let mut parser = Parser::new();
+ for byte in INPUT {
+ parser.advance(&mut dispatcher, *byte);
+ }
+
+ // Check that flag is set and thus osc_dispatch assertions ran.
+ assert_eq!(dispatcher.params[0], &[b'2']);
+ assert_eq!(dispatcher.params[1], &INPUT[5..(INPUT.len() - 1)]);
+ }
}
diff --git a/src/table.rs b/src/table.rs
index 5bb52c0..799c6d6 100644
--- a/src/table.rs
+++ b/src/table.rs
@@ -31,16 +31,16 @@ pub static STATE_CHANGE: [[u8; 256]; 16] =
0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,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u8, 0u8, 0u8, 0u8, 0u8,
+ 0u8, 0u8, 0u8, 0u8],
[80u8, 80u8, 80u8, 80u8, 80u8, 80u8, 80u8, 80u8, 80u8, 80u8, 80u8, 80u8,
80u8, 80u8, 80u8, 80u8, 80u8, 80u8, 80u8, 80u8, 80u8, 80u8, 80u8, 80u8,
0u8, 80u8, 0u8, 0u8, 80u8, 80u8, 80u8, 80u8, 35u8, 35u8, 35u8, 35u8,
@@ -302,16 +302,20 @@ pub static STATE_CHANGE: [[u8; 256]; 16] =
144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8,
144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8,
144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8,
- 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 0u8, 0u8, 0u8, 0u8,
- 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
- 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 12u8, 0u8, 0u8, 0u8,
- 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
- 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
- 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
- 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
- 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
- 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
- 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8],
+ 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8,
+ 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8,
+ 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8,
+ 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8,
+ 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8,
+ 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8,
+ 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8,
+ 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8,
+ 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8,
+ 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8,
+ 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8,
+ 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8,
+ 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8, 144u8,
+ 144u8, 144u8, 144u8, 144u8, 144u8],
[112u8, 112u8, 112u8, 112u8, 112u8, 112u8, 112u8, 112u8, 112u8, 112u8,
112u8, 112u8, 112u8, 112u8, 112u8, 112u8, 112u8, 112u8, 112u8, 112u8,
112u8, 112u8, 112u8, 112u8, 0u8, 112u8, 0u8, 0u8, 112u8, 112u8, 112u8,
diff --git a/src/table.rs.in b/src/table.rs.in
index 3017e33..5593283 100644
--- a/src/table.rs.in
+++ b/src/table.rs.in
@@ -7,18 +7,7 @@ pub static STATE_CHANGE: [[u8; 256]; 16] = vt_state_table! {
State::Anywhere => {
0x18 => (Action::Execute, State::Ground),
0x1a => (Action::Execute, State::Ground),
- 0x80...0x8f => (Action::Execute, State::Ground),
- 0x91...0x97 => (Action::Execute, State::Ground),
- 0x99 => (Action::Execute, State::Ground),
- 0x9a => (Action::Execute, State::Ground),
- 0x9c => (Action::Execute, State::Ground),
0x1b => State::Escape,
- 0x98 => State::SosPmApcString,
- 0x9e => State::SosPmApcString,
- 0x9f => State::SosPmApcString,
- 0x90 => State::DcsEntry,
- 0x9d => State::OscString,
- 0x9b => State::CsiEntry,
},
State::Ground => {
@@ -178,8 +167,7 @@ pub static STATE_CHANGE: [[u8; 256]; 16] = vt_state_table! {
0x08...0x17 => Action::Ignore,
0x19 => Action::Ignore,
0x1c...0x1f => Action::Ignore,
- 0x20...0x7f => Action::OscPut,
- 0x9c => State::Ground,
+ 0x20...0xff => Action::OscPut,
}
};