Live data from Hacker News

With Firefox on X11, any page can pastejack you anytime (middle button paste)

openwall.com

91–100 of 195 posts

Re: With Firefox on X11, any page can pastejack you anytime (middle button paste)

#91

You guys have a middle button? Maaaan. :) Edit: did y'all miss the smiley at the end of my comment?

You can set up eg. a 3-finger touchpad tap gesture for the middle button in KDE Plasma, I'm assuming the same should be possible under GNOME. No need for fancy touchpads.

I think that's a default for anybody using the libinput driver or the synaptics driver.

Re: With Firefox on X11, any page can pastejack you anytime (middle button paste)

#92

Earlier quoted context omitted.

it doesn’t not support it, it doesn’t set this unexpected behaviour as default

Whether it's unexpected or not depends on the user, you could as well say ctrl+v pasting in windows is unexpected if you don't know this shortcut. Middle click paste in linux is a standard feature this OS has always had

The problem being that middle click does other stuff, like opening links in new browser tabs.

Re: With Firefox on X11, any page can pastejack you anytime (middle button paste)

#93

Earlier quoted context omitted.

I love middle click paste, in combination with ctrl+c/ctrl+v paste it's a second clipboard, which allows to do one kind of refactoring in between doing some other refactoring in code (as just one example). I didn't know wayland doesn't support that either, one more thing to add to the list of things it doesn't support like screenshots, xclip, mouse/keyboard automation, etc...

it doesn’t not support it, it doesn’t set this unexpected behaviour as default

Middle click paste is very much expected - it’s been standard for at least a quarter of a century

Re: With Firefox on X11, any page can pastejack you anytime (middle button paste)

#94

Gentoo is great! cd /etc/portage/patches/www-client/firefox/ nano nomiddleclickhijack.patch #paste patch, save emerge -av firefox

I mean sure but what happens when you have a bunch of patches and updates for the package and it becomes a mess of merge conflicts?

Re: With Firefox on X11, any page can pastejack you anytime (middle button paste)

#95
post #31

The X “primary selection”/middle click paste behavior this takes advantage of is one of my least favorite Linux features and I have had it disabled for years, so I didn’t even know it had been changed/removed in Wayland. Having a single mouse button (that often has other functionality like autoscroll in Firefox) cause text highlighted in another app to paste in the focused app is super unintuitive to me, and caused a…

I love middle click paste, in combination with ctrl+c/ctrl+v paste it's a second clipboard, which allows to do one kind of refactoring in between doing some other refactoring in code (as just one example). I didn't know wayland doesn't support that either, one more thing to add to the list of things it doesn't support like screenshots, xclip, mouse/keyboard automation, etc...

> things it doesn't support like xclip

https://github.com/bugaevc/wl-clipboard

$ cat ~/bin/clip

    #!/bin/sh
    
    if [[ -z $WAYLAND_DISPLAY ]]; then
      xclip -selection clipboard
    else
      wl-copy
    fi

Re: With Firefox on X11, any page can pastejack you anytime (middle button paste)

#96
post #31

The X “primary selection”/middle click paste behavior this takes advantage of is one of my least favorite Linux features and I have had it disabled for years, so I didn’t even know it had been changed/removed in Wayland. Having a single mouse button (that often has other functionality like autoscroll in Firefox) cause text highlighted in another app to paste in the focused app is super unintuitive to me, and caused a…

I want to share a related annoyance. I installed Linux on an old laptop. When I want to scroll using a touchpad with two finger swipe, sometimes it triggers a two finger tap, which is a middle click - which then pastes the clipboard content. Mildly frustrating when editing code or browsing chat apps.

Tried a few solutions but they didn't work on Wayland (as most of them were xinput hacks).

I didn't experience such accidental pastes when I had Windows installed.

Re: With Firefox on X11, any page can pastejack you anytime (middle button paste)

#97
post #60
post #25

Earlier quoted context omitted.

Not that it matters, but it does not really put it into a buffer at least not in the sense that there is a place within X11 that is storing your selection. I think that when you paste the primary selection. X11 directs your application to the application that last selected something and you ask it for the selected bit in a specific (usually text) format. More on topic, this works fine within the trusted green zone of…

So in X11 if you select something then close the application then middle click paste into another application nothing will happen?

Some programs (such as xterm) will also use "cut buffers" (in addition to the primary selection, which is what is usually used for the middle button paste) which are retained even if the program is terminated. (Cut buffers are properties of the root window.)

Re: With Firefox on X11, any page can pastejack you anytime (middle button paste)

#98
post #2

Who pastes something and executes it without a second look?

Why is it so easy to find people in this industry who don't care that users can't trust their own computers (or, by extension, anything they own with a computer in it, which is quickly becoming everything)? If I select some text and press Ctrl+C, it should copy the text I selected. The user intent is obvious. There's no excuse for the ability to hijack the clipboard to exist in the first place. Web pages shouldn't be…

A computer is a tool and also a consumer device. I think most of us are in some sense selling the output of the tool (for example a programmer sells programs, not computers). Since we are not selling computers, we’re not automatically concerned with whether people are happy with their computers.

If you went to a scissor factory and told them that their scissors were too sharp, they might at least think of doing a run of safety scissors. If you go to a tailor and suggest that, they will probably be confused and not very receptive.

Re: With Firefox on X11, any page can pastejack you anytime (middle button paste)

#99

> For firefox running in Wayland, `writeXPrimary()` will only succeed when the firefox window (the main window, not necessarily the tab the code runs in) has the focus. Otherwise the selection will be cleared. At first I assumed that this is something specific to the Wayland protocol, but that turned out to be utterly false; it's just some quirk, bug or "feature" specific to either firefox itself or GTK. Most Wayland…

> Additionally, the Wayland protocol carries an event identifier, so that the compositor can tie the clipboard request to a pointer/keyboard/touch event and take a better decision.

That's actually not the case. There's a serial number that the client provides when they want to set the selection (that is, cut/copy)[0][1], but nothing when a client requests a paste[2][3].

I always thought this is weird; while yes, it's nice to prevent random applications from spuriously taking over as the source of the clipboard/primary, I think it's much more important to have a mechanism to reduce the risk of a client pasting without permission.

[0] https://wayland.app/protocols/wayland#wl_data_device:request... (regular clipboard)

[1] https://wayland.app/protocols/primary-selection-unstable-v1#... (primary selection)

[2] https://wayland.app/protocols/wayland#wl_data_offer:request:... (regular clipboard)

[3] https://wayland.app/protocols/primary-selection-unstable-v1#... (primary selection)

Re: With Firefox on X11, any page can pastejack you anytime (middle button paste)

#100
post #31

The X “primary selection”/middle click paste behavior this takes advantage of is one of my least favorite Linux features and I have had it disabled for years, so I didn’t even know it had been changed/removed in Wayland. Having a single mouse button (that often has other functionality like autoscroll in Firefox) cause text highlighted in another app to paste in the focused app is super unintuitive to me, and caused a…

Ha, I love it, but never figured out how to do by keyboard, even though I believe to sometimes have done it by accident.

In places where this doesn't work, clipboard history is an okay replacement (if you need multiple things "transported").

Post reply on HN