! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
dangerous paste confirmation dialog option disables bracketed paste mode
Status:
RESOLVED: FIXED
Product:
Xfce4-terminal
Component:
General

Comments

Description symphorien_xfce 2020-04-12 16:38:49 CEST
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.
Comment 1 symphorien_xfce 2020-04-12 17:35:15 CEST
Created attachment 9709 
proposed patch
Comment 2 symphorien_xfce 2020-04-12 17:37:16 CEST
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.
Comment 3 inactive 2020-04-16 14:28:54 CEST
am I missing something or, in your patch, res_text no longer converting \x0A to \x0D ?
Comment 4 inactive 2020-04-16 14:30:44 CEST
oh, yep, "However, when using vte_terminal_paste_clipboard/primary(), the text gets pasted correctly."
Comment 5 Git Bot editbugs 2020-04-19 01:07:33 CEST
Igor referenced this bugreport in commit 50fccff2872179e686ecb544253381dc520e9ec0

Unsafe paste: Support bracketed paste mode

https://git.xfce.org/apps/xfce4-terminal/commit?id=50fccff2872179e686ecb544253381dc520e9ec0
Comment 6 Igor editbugs 2020-04-19 01:08:50 CEST
Thank you for the report and the patch! I've merged it.
Comment 7 Igor editbugs 2020-04-20 19:43:46 CEST
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?
Comment 8 Igor editbugs 2020-04-20 19:45:39 CEST
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.
Comment 9 symphorien_xfce 2020-04-20 20:36:58 CEST
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.
Comment 10 Igor editbugs 2020-04-20 20:43:23 CEST
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.
Comment 11 Git Bot editbugs 2020-04-20 22:15:23 CEST
Igor referenced this bugreport in commit edcd23c62f721ecf23e852ded9191892b9d0c87f

Do not override clipboard contents

https://git.xfce.org/apps/xfce4-terminal/commit?id=edcd23c62f721ecf23e852ded9191892b9d0c87f
Comment 12 inactive 2020-04-21 00:04:46 CEST
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);

Bug #16682

Reported by:
symphorien_xfce
Reported on: 2020-04-12
Last modified on: 2020-04-21

People

CC List:
1 user

Version

Attachments

proposed patch (3.76 KB, patch)
2020-04-12 17:35 CEST , symphorien_xfce
no flags

Additional information