Overview: When dangerous paste confirmation dialog is enabled, bracketed paste mode is ignored. As far as I understand, bracketed paste mode is a special behavior explicitly requested by applications, so there is no reason to refuse it in some cases. Steps to reproduce 1/ in settings, enable the dangerous paste confirmation dialog 2/ run bash, and then bind 'set enable-bracketed-paste on' 3/ select multiple lines of text 4/ in bash, middle-click 5/ when the dangerous paste dialog shows up, accept Actual behaviour: [symphorien@nlaptop:~]$ foo foo: command not found [symphorien@nlaptop:~]$ foo foo: command not found [symphorien@nlaptop:~]$ bar The program ‘bar’ is currently not installed. You can install it by typing: nix-env -iA nixos.bar [symphorien@nlaptop:~]$ bar The program ‘bar’ is currently not installed. You can install it by typing: nix-env -iA nixos.bar [symphorien@nlaptop:~]$ baz baz: command not found [symphorien@nlaptop:~]$ baz baz: command not found [symphorien@nlaptop:~]$ Expected behavior [symphorien@nlaptop:~]$ foo foo bar bar baz baz xterm behaves this way, and xfce4-terminal as well IF the dangerous paste confirmation dialog is disabled.
Created attachment 9709 proposed patch
I attached a possible patch for this functionality. The only way I found to paste text in bracketed mode with libvte is through the clipboard so this patch * loads the possibly modified text of the dialog in the original clipboard * then uses the corresponding paste function.
am I missing something or, in your patch, res_text no longer converting \x0A to \x0D ?
oh, yep, "However, when using vte_terminal_paste_clipboard/primary(), the text gets pasted correctly."
Igor referenced this bugreport in commit 50fccff2872179e686ecb544253381dc520e9ec0 Unsafe paste: Support bracketed paste mode https://git.xfce.org/apps/xfce4-terminal/commit?id=50fccff2872179e686ecb544253381dc520e9ec0
Thank you for the report and the patch! I've merged it.
Actually, now that I've thought about this a little more... The change that has been merged effectively replaces the contents of the clipboard once the text gets pasted from the dialog. And I think this is exactly what I was trying to avoid by using vte_terminal_feed_child(). Perhaps there's another way to resolve the bracketed paste mode problem?
Obviously, one way would be to store the original clipboard contents and restore it once the paste is done. Maybe this is the way to go.
I've come to think that this could be a feature. The user copies some text, but it's not perfectly what they want to paste: xfce terminal gives a way to do the modification, and persist it. Why would one *not* paste a text as is but keep it in the clipboard ? Both ways of doing it can be defended.
The text that's in the clipboard might not be suitable (i.e. "dangerous") for pasting into a terminal but at the same time be perfectly fine to paste in e.g. a text editor. I really don't think the terminal should be managing or modifying the clipboard contents. The "unsafe paste" feature's goal is only to protect the user from unintentionally executing commands in the terminal.
Igor referenced this bugreport in commit edcd23c62f721ecf23e852ded9191892b9d0c87f Do not override clipboard contents https://git.xfce.org/apps/xfce4-terminal/commit?id=edcd23c62f721ecf23e852ded9191892b9d0c87f
Just wondering, without having tested this, if the clipboard is too big (megabytes), then during that paste, would the modified paste still be available to paste in say 'mousepad' before the previous xfce4-terminal paste completes? $ seq 1 10000|tr '\n' ' ' This gives one long line, if pasted, it takes a few seconds to complete, does that mean that the text that I am able to paste in 'mousepad' meanwhile, is the modified clipboard? Can someone give an example of a clipboard text that would be modified by that code: GtkTextBuffer *buffer = gtk_text_view_get_buffer (tv); //... gtk_text_buffer_get_bounds (buffer, &start, &end); res_text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE); if (res_text != NULL) { /* Modify the content of the clipboard as required, and then paste it. * Using the builtin pasting function enables bracketed paste mode when applicable. */ GtkClipboard *clipboard = gtk_clipboard_get (original_clipboard); gtk_clipboard_set_text (clipboard, res_text, strlen (res_text)); g_free (res_text);