From 9063d02cf1db40b3b342544c6b74f8641de789ce Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Mon, 3 Apr 2023 22:07:00 -0400 Subject: [PATCH] Fix formatting of strings being fed through printf for X11 and MacOS Former-commit-id: 1056b7c8efb6193ce4b43a7d72b2151aabee3559 Former-commit-id: c7b16925d45d3cffba08bac600044954e9561bd8 --- lib/sshyp.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/sshyp.py b/lib/sshyp.py index 4f8d89d..7949d17 100755 --- a/lib/sshyp.py +++ b/lib/sshyp.py @@ -707,13 +707,15 @@ def copy_data(): # copies a specified field of an entry to the clipboard run(['clipboard', '-c', _copy_line[_index].rstrip()]) Popen('sleep 30; clipboard -r', shell=True) elif uname()[0] == 'Darwin': # MacOS clipboard detection - run(['pbcopy'], stdin=Popen(['printf', _copy_line[_index].rstrip()], stdout=PIPE).stdout) + run(['pbcopy'], stdin=Popen(['printf', _copy_line[_index].rstrip().replace('\\', '\\\\').replace('%', '%%')], + stdout=PIPE).stdout) Popen("sleep 30; printf '' | pbcopy", shell=True) elif exists("/data/data/com.termux"): # Termux (Android) clipboard detection run(['termux-clipboard-set', _copy_line[_index].rstrip()]) Popen("sleep 30; termux-clipboard-set ''", shell=True) else: # X11 clipboard detection - run(['xclip', '-sel', 'c'], stdin=Popen(['printf', _copy_line[_index].rstrip()], stdout=PIPE).stdout) + run(['xclip', '-sel', 'c'], stdin=Popen(['printf', _copy_line[_index].rstrip().replace('\\', '\\\\') + .replace('%', '%%')], stdout=PIPE).stdout) Popen("sleep 30; printf '' | xclip -sel c", shell=True) rmtree(f"{tmp_dir}{_shm_folder}")