diff options
author | Christian Duerr <contact@christianduerr.com> | 2023-02-23 19:57:18 +0100 |
---|---|---|
committer | Christian Duerr <contact@christianduerr.com> | 2023-03-06 08:19:58 +0100 |
commit | ea93d7f4518bb78b57f71311df1728dfd45b9055 (patch) | |
tree | 0957f86450976a675310a0f0c385b9b6579d7167 | |
parent | e292aedf27ce97015a203365378515629d3df3c5 (diff) | |
download | alacritty-ea93d7f4518bb78b57f71311df1728dfd45b9055.tar.gz alacritty-ea93d7f4518bb78b57f71311df1728dfd45b9055.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.md | 1 | ||||
-rw-r--r-- | alacritty/src/event.rs | 10 |
2 files changed, 10 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index f88b576d..38c410b8 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 |