aboutsummaryrefslogtreecommitdiff
path: root/alacritty_terminal/src
diff options
context:
space:
mode:
authorKirill Chibisov <contact@kchibisov.com>2023-03-19 18:16:28 +0300
committerGitHub <noreply@github.com>2023-03-19 18:16:28 +0300
commit4b91a1dbe97d209273290480f58480f48fa4af97 (patch)
tree982b0782d1326667c7f522fcfefef6db9df0616c /alacritty_terminal/src
parent2377c0a7280f31ccc46953c462823ee3a1083af5 (diff)
downloadalacritty-4b91a1dbe97d209273290480f58480f48fa4af97.tar.gz
alacritty-4b91a1dbe97d209273290480f58480f48fa4af97.zip
Fix `;` character in URI OSC 8 payload
The special character `;` can be not URL-encoded, thus it'll add extra parameter in the payload. Handle it joining extra parameters with the `;` as a separator.
Diffstat (limited to 'alacritty_terminal/src')
-rw-r--r--alacritty_terminal/src/ansi.rs10
-rw-r--r--alacritty_terminal/src/term/cell.rs6
2 files changed, 12 insertions, 4 deletions
diff --git a/alacritty_terminal/src/ansi.rs b/alacritty_terminal/src/ansi.rs
index 53495995..c47007d8 100644
--- a/alacritty_terminal/src/ansi.rs
+++ b/alacritty_terminal/src/ansi.rs
@@ -1014,7 +1014,15 @@ where
// Hyperlink.
b"8" if params.len() > 2 => {
let link_params = params[1];
- let uri = str::from_utf8(params[2]).unwrap_or_default();
+
+ // NOTE: The escape sequence is of form 'OSC 8 ; params ; URI ST', where
+ // URI is URL-encoded. However `;` is a special character and might be
+ // passed as is, thus we need to rebuild the URI.
+ let mut uri = str::from_utf8(params[2]).unwrap_or_default().to_string();
+ for param in params[3..].iter() {
+ uri.push(';');
+ uri.push_str(str::from_utf8(param).unwrap_or_default());
+ }
// The OSC 8 escape sequence must be stopped when getting an empty `uri`.
if uri.is_empty() {
diff --git a/alacritty_terminal/src/term/cell.rs b/alacritty_terminal/src/term/cell.rs
index bd331c68..3e7d09e5 100644
--- a/alacritty_terminal/src/term/cell.rs
+++ b/alacritty_terminal/src/term/cell.rs
@@ -43,7 +43,7 @@ pub struct Hyperlink {
}
impl Hyperlink {
- pub fn new<T: ToString>(id: Option<T>, uri: T) -> Self {
+ pub fn new<T: ToString>(id: Option<T>, uri: String) -> Self {
let inner = Arc::new(HyperlinkInner::new(id, uri));
Self { inner }
}
@@ -67,7 +67,7 @@ struct HyperlinkInner {
}
impl HyperlinkInner {
- pub fn new<T: ToString>(id: Option<T>, uri: T) -> Self {
+ pub fn new<T: ToString>(id: Option<T>, uri: String) -> Self {
let id = match id {
Some(id) => id.to_string(),
None => {
@@ -77,7 +77,7 @@ impl HyperlinkInner {
},
};
- Self { id, uri: uri.to_string() }
+ Self { id, uri }
}
}