diff --git a/docs/changelog.md b/docs/changelog.md index 95e0ebcf7..634d96dc5 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -135,6 +135,9 @@ As features stabilize some brief notes about them will accumulate here. * macOS: honor the `window_close_confirmation` config option when quitting the application. Thanks to @quantonganh! #4420 #4362 * terminfo: added missing terminator to Sync capability. Thanks to @gpanders! #4578 +* bracketed paste escape sequences are now always stripped out of text + that is pasted into the terminal. This happens even if bracketed paste + mode is disabled. #4765 #### Updated * Bundled harfbuzz to 8.3.0 diff --git a/term/src/terminalstate/mod.rs b/term/src/terminalstate/mod.rs index 07c6d185e..6ee81f3b8 100644 --- a/term/src/terminalstate/mod.rs +++ b/term/src/terminalstate/mod.rs @@ -804,6 +804,8 @@ impl TerminalState { /// Send text to the terminal that is the result of pasting. /// If bracketed paste mode is enabled, the paste is enclosed /// in the bracketing, otherwise it is fed to the writer as-is. + /// De-fang the text by removing any embedded bracketed paste + /// sequence that may be present. pub fn send_paste(&mut self, text: &str) -> Result<(), Error> { let mut buf = String::new(); if self.bracketed_paste { @@ -817,7 +819,8 @@ impl TerminalState { }; let canon = canon.canonicalize(text); - buf.push_str(&canon); + let de_fanged = canon.replace("\x1b[200~", "").replace("\x1b[201~", ""); + buf.push_str(&de_fanged); if self.bracketed_paste { buf.push_str("\x1b[201~");