From 5af02866b4d3731e1d6c7500e787f54d8f50c002 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Sun, 24 Sep 2023 18:56:42 -0400 Subject: [PATCH] Fixed clipboard contents leaking through process list on Wayland Former-commit-id: bb1485fec2d891af9f49b4d8e81df72b0e6160d9 Former-commit-id: 2eff4ace8b82735a890bf1e669d92d7abbb59dfa --- lib/sshyp.py | 7 ++++--- port-jobs/CLIPBOARD.py | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/sshyp.py b/lib/sshyp.py index 059a619..99c47ec 100755 --- a/lib/sshyp.py +++ b/lib/sshyp.py @@ -544,7 +544,8 @@ def copy_data(): Popen("sleep 30; powershell.exe -c Set-Clipboard ''", shell=True, stdout=DEVNULL, stderr=DEVNULL) # Wayland clipboard detection elif 'WAYLAND_DISPLAY' in environ: - run(('wl-copy', _copy_subject)) + run('wl-copy', stdin=Popen(('printf', _copy_subject.replace('\\', '\\\\').replace('%', '%%')), + stdout=PIPE).stdout) Popen('sleep 30; wl-copy -c', shell=True) # Haiku clipboard detection elif uname()[0] == 'Haiku': @@ -561,9 +562,9 @@ def copy_data(): Popen("sleep 30; termux-clipboard-set ''", shell=True) # X11 clipboard detection elif 'DISPLAY' in environ: - run(('xclip', '-sel', 'c'), stdin=Popen(('printf', _copy_subject.replace('\\', '\\\\') + run(('xclip', '-se', 'c'), stdin=Popen(('printf', _copy_subject.replace('\\', '\\\\') .replace('%', '%%')), stdout=PIPE).stdout) - Popen("sleep 30; printf '' | xclip -sel c", shell=True) + Popen("sleep 30; printf '' | xclip -se c", shell=True) else: print('\n\u001b[38;5;9merror: clipboard tool could not be determined\n\nnote that the clipboard does not ' 'function in a raw tty\u001b[0m\n') diff --git a/port-jobs/CLIPBOARD.py b/port-jobs/CLIPBOARD.py index 406ad5e..43f4540 100755 --- a/port-jobs/CLIPBOARD.py +++ b/port-jobs/CLIPBOARD.py @@ -22,7 +22,8 @@ if len(arguments) > 0: Popen("sleep 30; termux-clipboard-set ''", shell=True)""" elif arguments[0] == 'LINUX': replacement = """if 'WAYLAND_DISPLAY' in environ: - run(('wl-copy', _copy_subject)) + run('wl-copy', stdin=Popen(('printf', _copy_subject + .replace('\\\\\\', '\\\\\\\\\\\\\\').replace('%', '%%')), stdout=PIPE).stdout) Popen('sleep 30; wl-copy -c', shell=True) else: run(('xclip', '-sel', 'c'), stdin=Popen(('printf', _copy_subject