Bug 431695 - Pasting \n does not work
Summary: Pasting \n does not work
Alias: None
Product: konsole
Classification: Applications
Component: copy-paste (show other bugs)
Version: 20.12.1
Platform: Other Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: Konsole Developer
: 443292 (view as bug list)
Depends on:
Reported: 2021-01-16 15:31 UTC by Dmitri Koulikoff
Modified: 2022-04-29 18:30 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:

Copy new line (300.00 KB, video/mp4)
2021-01-26 11:26 UTC, Carlos Alves

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitri Koulikoff 2021-01-16 15:31:56 UTC

When I paste a commend that is ended with \n (newline) it is not executed until I press Enter.

1. Create a line command in any text editor, say "ls"
2. Select this line with the ending \n
3. Go to the konsole and press the middle button


The command will be pasted with the \n but is not executed


The command should be pasted AND executed

Operating System: Slackware-current
KDE Plasma Version: 5.20.5
KDE Frameworks Version: 5.78.0
Qt Version: 5.15.2
Kernel Version: 5.10.6
OS Type: 64-bit
Processors: 12 × Intel® Core™ i7-9750H CPU @ 2.60GHz
Memory: 31.1 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics 630
Comment 1 Nate Graham 2021-01-26 06:05:39 UTC
If we did this, it would be possible for people to copy-paste malicious code they find online that executes immediately.
Comment 2 Dmitri Koulikoff 2021-01-26 07:50:42 UTC
It makes no difference for them as they will press Enter as well.
Comment 3 Carlos Alves 2021-01-26 11:26:25 UTC
Created attachment 135202 [details]
Copy new line

It is already possible to copy a new line, you have to select the line until the beginning of next line, this way it will select the '\n'.
Comment 4 Dmitri Koulikoff 2021-01-26 11:43:00 UTC
Yes, it does insert, but not reacts. So I need to press Enter every time. It is very annoying. If you insist that new behaviour should exist, there should be a setting for it.
Comment 5 tcanabrava 2021-01-26 11:46:43 UTC
Dmitri, I won't be adding a setting for this.

I agree with the other users that this is a security concern, and it's doable that a ctrl + c on a website can inject malicius code, so you have the opportunity to check if the pasted command is indeed `ls -l` instead of `sudo rm -rf /`

Press enter if you copy / paste code.
or, create functions on your bashrc with the appropriate code that you are pasting so often.

Comment 6 Ahmad Samir 2021-01-26 12:05:42 UTC
I don't think this is specific to konsole; bash/readline has bracketed-paste, if it's enabled the shell will behave the way you describe.

You can enable/disable bracketed-paste by editing /etc/inputrc and adding a line:
set enable-bracketed-paste off


(If you want the change to be in your user account only, you can also create a ~/.inputrc file:
$include /etc/inputrc
set enable-bracketed-paste off

Note that bash/readline in recent versions have enabled bracketed-paste by default: https://lwn.net/Articles/839212/
Comment 7 Dmitri Koulikoff 2021-01-26 12:47:19 UTC
Comment 8 Ahmad Samir 2022-04-29 18:30:35 UTC
*** Bug 443292 has been marked as a duplicate of this bug. ***