aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2023-02-23 19:57:18 +0100
committerGitHub <noreply@github.com>2023-02-23 18:57:18 +0000
commitf01dea8643e2956d2480ee12c3e5ee960944a49d (patch)
tree77c006043a991e98d73cbc94cfbc53480a4cd8e5
parent79ea8b9482ec07b894ea9f6a0a79712751fe151c (diff)
downloadalacritty-f01dea8643e2956d2480ee12c3e5ee960944a49d.tar.gz
alacritty-f01dea8643e2956d2480ee12c3e5ee960944a49d.zip
Fix bracketed paste with EOT payload
This works around an issue in many (all?) shells where the bracketed paste logic would only strip out `\r` but interpret EOT (`\x03`) as a termination of the bracketed paste.
-rw-r--r--CHANGELOG.md1
-rw-r--r--alacritty/src/event.rs10
2 files changed, 10 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4b82d1c9..7d19290e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -47,6 +47,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Redraw hanging until a keypress on X11 in rare cases
- Window clipping when maximizing a window without decorations on Windows
- Quadrants not aligned with half blocks with built-in font
+- EOT (`\x03`) escaping bracketed paste mode
### Removed
diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs
index 5eafc09c..3ecca5e8 100644
--- a/alacritty/src/event.rs
+++ b/alacritty/src/event.rs
@@ -790,7 +790,15 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> for ActionCon
}
} else if self.terminal().mode().contains(TermMode::BRACKETED_PASTE) {
self.write_to_pty(&b"\x1b[200~"[..]);
- self.write_to_pty(text.replace('\x1b', "").into_bytes());
+
+ // Write filtered escape sequences.
+ //
+ // We remove `\x1b` to ensure it's impossible for the pasted text to write the bracketed
+ // paste end escape `\x1b[201~` and `\x03` since some shells incorrectly terminate
+ // bracketed paste on its receival.
+ let filtered = text.replace('\x1b', "").replace('\x03', "");
+ self.write_to_pty(filtered.into_bytes());
+
self.write_to_pty(&b"\x1b[201~"[..]);
} else {
// In non-bracketed (ie: normal) mode, terminal applications cannot distinguish