de-fang paste payloads by removing bracketed paste sequences from them

refs: https://github.com/wez/wezterm/issues/4765
This commit is contained in:
Wez Furlong committed 2024-01-08 18:17:22 -07:00
1 parent 8023948647
commit 9fc89e621f
2 files changed
+7 -1

No files matched your search

+3
View File
@@ -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
+4 -1
View File
@@ -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~");