mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-18 17:56:09 +03:00

Thanks to: https://thejh.net/misc/website-terminal-copy-paste If a paste has the ending sentinel value for a bracketed paste ("\x1b[201~") then the shell may start processing data faster. We now consider this unsafe even if the `clipboard-paste-bracketed-safe` setting is true.
15 lines
440 B
Zig
15 lines
440 B
Zig
const std = @import("std");
|
|
|
|
/// Returns true if the data looks safe to paste.
|
|
pub fn isSafePaste(data: []const u8) bool {
|
|
return std.mem.indexOf(u8, data, "\n") == null and
|
|
std.mem.indexOf(u8, data, "\x1b[201~") == null;
|
|
}
|
|
|
|
test isSafePaste {
|
|
const testing = std.testing;
|
|
try testing.expect(isSafePaste("hello"));
|
|
try testing.expect(!isSafePaste("hello\n"));
|
|
try testing.expect(!isSafePaste("hello\nworld"));
|
|
}
|