1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-24 13:52:55 +03:00

termwiz: allow degenerate empty parameter in iTerm2 protocol

The `bv` utility emits this slightly wonky sequence; since iTerm2 allows
it, we should also allow it.

refs: #1291
This commit is contained in:
Wez Furlong 2021-11-05 08:08:03 -07:00
parent 154691a196
commit f56a6aa276
2 changed files with 30 additions and 0 deletions

View File

@ -884,6 +884,11 @@ impl ITermFileData {
param
};
// eg: `File=;size=1234` case. <https://github.com/wez/wezterm/issues/1291>
if param.is_empty() {
continue;
}
// look for k=v in param
if let Some(equal) = param.iter().position(|c| *c == b'=') {
let key = &param[..equal];

View File

@ -1023,4 +1023,29 @@ mod test {
]
);
}
#[test]
fn issue_1291() {
use crate::escape::osc::{ITermDimension, ITermFileData, ITermProprietary};
let mut p = Parser::new();
// Note the empty k=v pair immediately following `File=`
let actions = p.parse_as_vec(b"\x1b]1337;File=;size=234:aGVsbG8=\x07");
assert_eq!(
vec![Action::OperatingSystemCommand(Box::new(
OperatingSystemCommand::ITermProprietary(ITermProprietary::File(Box::new(
ITermFileData {
name: None,
size: Some(234),
width: ITermDimension::Automatic,
height: ITermDimension::Automatic,
preserve_aspect_ratio: true,
inline: false,
data: b"hello".to_vec(),
}
)))
))],
actions
);
}
}