mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 00:36:07 +03:00
core: do not consider bracketed pastes unsafe
This commit is contained in:
@ -2500,31 +2500,41 @@ fn completeClipboardPaste(
|
|||||||
) !void {
|
) !void {
|
||||||
if (data.len == 0) return;
|
if (data.len == 0) return;
|
||||||
|
|
||||||
// If we have paste protection enabled, we detect unsafe pastes and return
|
const critical: struct {
|
||||||
// an error. The error approach allows apprt to attempt to complete the paste
|
bracketed: bool,
|
||||||
// before falling back to requesting confirmation.
|
} = critical: {
|
||||||
if (self.config.clipboard_paste_protection and
|
|
||||||
!allow_unsafe and
|
|
||||||
!terminal.isSafePaste(data))
|
|
||||||
{
|
|
||||||
log.info("potentially unsafe paste detected, rejecting until confirmation", .{});
|
|
||||||
return error.UnsafePaste;
|
|
||||||
}
|
|
||||||
|
|
||||||
const bracketed = bracketed: {
|
|
||||||
self.renderer_state.mutex.lock();
|
self.renderer_state.mutex.lock();
|
||||||
defer self.renderer_state.mutex.unlock();
|
defer self.renderer_state.mutex.unlock();
|
||||||
|
|
||||||
|
const bracketed = self.io.terminal.modes.get(.bracketed_paste);
|
||||||
|
|
||||||
|
// If we have paste protection enabled, we detect unsafe pastes and return
|
||||||
|
// an error. The error approach allows apprt to attempt to complete the paste
|
||||||
|
// before falling back to requesting confirmation.
|
||||||
|
//
|
||||||
|
// We do not do this for bracketed pastes because bracketed pastes are
|
||||||
|
// by definition safe since they're framed.
|
||||||
|
if (!bracketed and
|
||||||
|
self.config.clipboard_paste_protection and
|
||||||
|
!allow_unsafe and
|
||||||
|
!terminal.isSafePaste(data))
|
||||||
|
{
|
||||||
|
log.info("potentially unsafe paste detected, rejecting until confirmation", .{});
|
||||||
|
return error.UnsafePaste;
|
||||||
|
}
|
||||||
|
|
||||||
// With the lock held, we must scroll to the bottom.
|
// With the lock held, we must scroll to the bottom.
|
||||||
// We always scroll to the bottom for these inputs.
|
// We always scroll to the bottom for these inputs.
|
||||||
self.scrollToBottom() catch |err| {
|
self.scrollToBottom() catch |err| {
|
||||||
log.warn("error scrolling to bottom err={}", .{err});
|
log.warn("error scrolling to bottom err={}", .{err});
|
||||||
};
|
};
|
||||||
|
|
||||||
break :bracketed self.io.terminal.modes.get(.bracketed_paste);
|
break :critical .{
|
||||||
|
.bracketed = bracketed,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
if (bracketed) {
|
if (critical.bracketed) {
|
||||||
// If we're bracketd we write the data as-is to the terminal with
|
// If we're bracketd we write the data as-is to the terminal with
|
||||||
// the bracketed paste escape codes around it.
|
// the bracketed paste escape codes around it.
|
||||||
_ = self.io_thread.mailbox.push(.{
|
_ = self.io_thread.mailbox.push(.{
|
||||||
|
Reference in New Issue
Block a user