Live data from Hacker News

Don't Copy-Paste from Website to Terminal

thejh.net

1–10 of 272 posts

Re: Don't Copy-Paste from Website to Terminal

#5

Note: if you don't trust this, paste into a text editor! It works with this CSS: position: absolute; left: -100px; top: -100px

I wonder if you could do the same with Unicode control characters. There's probably something in the depths of the library that would have a similar outcome.

Re: Don't Copy-Paste from Website to Terminal

#6
Bash and Zsh provide shortcuts to open a text editor where commands can be pasted and edited before running (Ctrl-x Ctrl-e in bash, need to enable in zsh [2]). I've been using this on Linux not for security but because I'm still confused by X11's primary and clipboard selections [1]. It seems like every time I try to paste a github repo link, I get the last chunk of code I copied and vice versa.

[1] http://www.nongnu.org/autocutsel/

[2] Sample .zshrc to map edit-command-line to Ctrl-x e:

  autoload edit-command-line
  zle -N edit-command-line
  bindkey '^Xe' edit-command-line
edit: fixed shortcut for bash

edit: forgot about my .zshrc

Re: Don't Copy-Paste from Website to Terminal

#7
Nicely done! Here's the underlying source:

    
      
      git clone
      /dev/null; clear; echo -n "Hello ";whoami|tr -d '\n';echo -e '!\nThat was a bad idea. Don'"'"'t copy code from websites you don'"'"'t trust!
Here'"'"'s the first line of your /etc/passwd: ';head -n1 /etc/passwd
git clone git://git.kernel.org/pub/scm/utils/kup/kup.git

Re: Don't Copy-Paste from Website to Terminal

#8
Pasted result is:

  git clone

  /dev/null; clear; echo -n "Hello ";whoami|tr -d '\n';echo -e '!\nThat was a bad idea. Don'"'"'t copy code from websites you don'"'"'t trust!

  Here'"'"'s the first line of your /etc/passwd: ';head -n1 /etc/passwd

  git clone git://git.kernel.org/pub/scm/utils/kup/kup.git

Re: Don't Copy-Paste from Website to Terminal

#9

Bash and Zsh provide shortcuts to open a text editor where commands can be pasted and edited before running (Ctrl-x Ctrl-e in bash, need to enable in zsh [2]). I've been using this on Linux not for security but because I'm still confused by X11's primary and clipboard selections [1]. It seems like every time I try to paste a github repo link, I get the last chunk of code I copied and vice versa. [1] http://www.nongnu…

Out of interest, what is confusing? If you select text it always goes into the selection buffer. If you also press the clipboard copy shortcut (so, Ctrl-C most of the time, sometimes Ctrl-Shift-C in a terminal) the selection is copied into the clipboard buffer.

Ctrl-V (or, again, sometimes Ctrl-Shift-V in a terminal) pastes the clipboard buffer. Middle mouse button (or shift-Insert) pastes the selection buffer.

Is there still room for confusion?

Re: Don't Copy-Paste from Website to Terminal

#10

Bash and Zsh provide shortcuts to open a text editor where commands can be pasted and edited before running (Ctrl-x Ctrl-e in bash, need to enable in zsh [2]). I've been using this on Linux not for security but because I'm still confused by X11's primary and clipboard selections [1]. It seems like every time I try to paste a github repo link, I get the last chunk of code I copied and vice versa. [1] http://www.nongnu…

Ctrl-X + E doesn't appear to be doing anything in bash.
Post reply on HN