Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop dead feature that disables unsafe paste warning while Terminal opens #803

Merged
merged 3 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/Dialogs/UnsafePasteDialog.vala
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,11 @@ public class Terminal.UnsafePasteDialog : Granite.MessageDialog {

var ignore_button = (Gtk.Button) add_button (_("Paste Anyway"), Gtk.ResponseType.ACCEPT);
ignore_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);
ignore_button.clicked.connect (on_ignore);

set_default_response (Gtk.ResponseType.CANCEL);

Terminal.Application.settings.bind (
"unsafe-paste-alert", show_protection_warnings, "active", SettingsBindFlags.DEFAULT
);
}

private void on_ignore () {
var terminal_window = get_transient_for ();
if (terminal_window is MainWindow) {
((MainWindow) terminal_window).unsafe_ignored = true;
}
}
}
1 change: 0 additions & 1 deletion src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ namespace Terminal {
private const int MAXIMIZED = 1;
private const int FULLSCREEN = 2;

public bool unsafe_ignored;
public bool focus_restored_tabs { get; construct; default = true; }
public bool recreate_tabs { get; construct; default = true; }
public Menu context_menu_model { get; private set; }
Expand Down
6 changes: 2 additions & 4 deletions src/Widgets/TerminalWidget.vala
Original file line number Diff line number Diff line change
Expand Up @@ -526,10 +526,7 @@ namespace Terminal {
// Check pasted and dropped text before feeding to child;
private void validated_feed (string? text) {
if (text != null && text.validate ()) {
unowned var toplevel = (MainWindow) get_toplevel ();
if (!toplevel.unsafe_ignored &&
Application.settings.get_boolean ("unsafe-paste-alert")) {

if (Application.settings.get_boolean ("unsafe-paste-alert")) {
string? warn_text = null;
if ("\n" in text) {
warn_text = _("The pasted text may contain multiple commands");
Expand All @@ -538,6 +535,7 @@ namespace Terminal {
}

if (warn_text != null) {
unowned var toplevel = (MainWindow) get_toplevel ();
var dialog = new UnsafePasteDialog (toplevel, warn_text, text.strip ());
dialog.response.connect ((res) => {
dialog.destroy ();
Expand Down