Copying

A demo showing how JavaScript can edit what you save to clipboard

When you copy code, text, or links to your clipboard from a website, JavaScript is able to edit what is saved. This can create security issues or general mishaps. Don’t always trust what you copy to your clipboard. This can be used to delete key files in your system if pasting to a terminal with root, as adding a newline into the clipboard will cause it to auto-execute.

Here is an example of how this could work. Try copying the sample of text below, then paste it into the text box.

Try copying this. What will be pasted will be different.

One way to get around this is browsing the internet with JavaScript off with tools such as uBlock Origin, but that can cause some pages to render poorly. Pages should be able to work without JavaScript, and it’s silly to make them completely fail to work without it.

From: Louis Petrik’s Why You Should Never Rashly Copy Commands From Websites

See also: Don’t copy anything from a website to your terminal