mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-08-28 04:46:34 -04:00
Call printf with %b to avoid interpreting directives
Former-commit-id: f1e812634d538b8e8c412b0c3aa1c43aab1c4f1b Former-commit-id: f95072b8742e752be18dc3fe9cba17c8e82eb41b
This commit is contained in:
+4
-6
@@ -553,8 +553,7 @@ def copy_data():
|
||||
"Set-Clipboard", shell=True, stdout=DEVNULL, stderr=DEVNULL)
|
||||
# Wayland clipboard detection
|
||||
elif 'WAYLAND_DISPLAY' in environ:
|
||||
run('wl-copy', stdin=Popen(('printf', _copy_subject.replace('\\', '\\\\').replace('%', '%%')),
|
||||
stdout=PIPE).stdout)
|
||||
run('wl-copy', stdin=Popen(('printf', '%b', _copy_subject.replace('\\', '\\\\')), stdout=PIPE).stdout)
|
||||
Popen(f"sleep 30; test \'{_hash.hexdigest() + 2*' ' + '-'}\' = \"$(printf \"$(wl-paste)\" | sha512sum)\" "
|
||||
"&& wl-copy -c", shell=True)
|
||||
# Haiku clipboard detection
|
||||
@@ -564,8 +563,7 @@ def copy_data():
|
||||
"&& clipboard -r", shell=True)
|
||||
# MacOS clipboard detection
|
||||
elif uname()[0] == 'Darwin':
|
||||
run('pbcopy', stdin=Popen(('printf', _copy_subject.replace('\\', '\\\\').replace('%', '%%')), stdout=PIPE)
|
||||
.stdout)
|
||||
run('pbcopy', stdin=Popen(('printf', '%b', _copy_subject.replace('\\', '\\\\')), stdout=PIPE).stdout)
|
||||
Popen(f"sleep 30; test \'{_hash.hexdigest() + 2 * ' ' + '-'}\' = \"$(printf \"$(pbpaste)\" | shasum -a 512)\" "
|
||||
"&& printf '' | pbcopy", shell=True)
|
||||
# Termux (Android) clipboard detection
|
||||
@@ -575,8 +573,8 @@ def copy_data():
|
||||
f"sha512sum)\" && termux-clipboard-set ''", shell=True)
|
||||
# X11 clipboard detection
|
||||
elif 'DISPLAY' in environ:
|
||||
run(('xclip', '-sel', 'c'), stdin=Popen(('printf', _copy_subject.replace('\\', '\\\\')
|
||||
.replace('%', '%%')), stdout=PIPE).stdout)
|
||||
run(('xclip', '-sel', 'c'), stdin=Popen(('printf', '%b', _copy_subject.replace('\\', '\\\\')), stdout=PIPE)
|
||||
.stdout)
|
||||
Popen(f"sleep 30; test \'{_hash.hexdigest() + 2*' ' + '-'}\' = \"$(printf \"$(xclip -o -sel c)\" | sha512sum)\""
|
||||
" && xclip -i /dev/null -sel c", shell=True)
|
||||
else:
|
||||
|
||||
+13
-28
@@ -9,45 +9,30 @@ arguments, replacement = argv[1:], None
|
||||
if len(arguments) > 0:
|
||||
if arguments[0] == 'WSL':
|
||||
replacement = """run(('powershell.exe', '-c', "Set-Clipboard '" + _copy_subject.replace("'", "''") + "'"))
|
||||
Popen("sleep 30; temp=$(echo \\"$(powershell.exe -Command \\'Get-FileHash -InputStream $([IO.MemoryStream]"
|
||||
"::new([byte[]][char[]]\\"$(Get-Clipboard)\\")) -Algorithm SHA512 | Select-Object -ExpandProperty "
|
||||
f"Hash\\')\\" | dos2unix); test \\'{_hash.hexdigest().upper()}\\' = \\"$temp\\" && powershell.exe -c "
|
||||
"Set-Clipboard", shell=True, stdout=DEVNULL, stderr=DEVNULL)"""
|
||||
Popen(f"sleep 30; temp=$(echo \\"$(powershell.exe -Command \\'Get-FileHash -InputStream $([IO.MemoryStream]::new([byte[]][char[]]\\"$(Get-Clipboard)\\")) -Algorithm SHA512 | Select-Object -ExpandProperty Hash\\')\\" | dos2unix); test \\'{_hash.hexdigest().upper()}\\' = \\"$temp\\" && powershell.exe -c Set-Clipboard", shell=True, stdout=DEVNULL, stderr=DEVNULL)"""
|
||||
elif arguments[0] == 'MAC':
|
||||
replacement = """run('pbcopy', stdin=Popen(('printf', _copy_subject.replace('\\\\\\', '\\\\\\\\\\\\\\')
|
||||
.replace('%', '%%')), stdout=PIPE).stdout)
|
||||
Popen(f"sleep 30; test \\'{_hash.hexdigest() + 2 * ' ' + '-'}\\' = \\"$(printf \\"$(pbpaste)\\" | shasum -a 512)\\" "
|
||||
"&& printf '' | pbcopy", shell=True)"""
|
||||
replacement = """run('pbcopy', stdin=Popen(('printf', '%b', _copy_subject.replace('\\\\\\', '\\\\\\\\\\\\\\')), stdout=PIPE).stdout)
|
||||
Popen(f"sleep 30; test \\'{_hash.hexdigest() + 2 * ' ' + '-'}\\' = \\"$(printf \\"$(pbpaste)\\" | shasum -a 512)\\" && printf '' | pbcopy", shell=True)"""
|
||||
elif arguments[0] == 'HAIKU':
|
||||
replacement = """run(('clipboard', '-c', _copy_subject))
|
||||
Popen(f"sleep 30; test \\'{_hash.hexdigest() + 2 * ' ' + '-'}\\' = \\"$(printf \\"$(clipboard -p)\\" | sha512sum)\\" "
|
||||
"&& clipboard -r", shell=True)"""
|
||||
Popen(f"sleep 30; test \\'{_hash.hexdigest() + 2 * ' ' + '-'}\\' = \\"$(printf \\"$(clipboard -p)\\" | sha512sum)\\" && clipboard -r", shell=True)"""
|
||||
elif arguments[0] == 'TERMUX':
|
||||
replacement = """run(('termux-clipboard-set', _copy_subject))
|
||||
Popen(f"sleep 30; test \\'{_hash.hexdigest() + 2 * ' ' + '-'}\\' = \\"$(printf \\"$(termux-clipboard-get)\\" | "
|
||||
f"sha512sum)\\" && termux-clipboard-set ''", shell=True)"""
|
||||
Popen(f"sleep 30; test \\'{_hash.hexdigest() + 2 * ' ' + '-'}\\' = \\"$(printf \\"$(termux-clipboard-get)\\" | sha512sum)\\" && termux-clipboard-set ''", shell=True)"""
|
||||
elif arguments[0] == 'LINUX':
|
||||
replacement = """if 'WAYLAND_DISPLAY' in environ:
|
||||
run('wl-copy', stdin=Popen(('printf', _copy_subject
|
||||
.replace('\\\\\\', '\\\\\\\\\\\\\\').replace('%', '%%')), stdout=PIPE).stdout)
|
||||
Popen(f"sleep 30; test \\'{_hash.hexdigest() + 2*' ' + '-'}\\' = \\"$(printf \\"$(wl-paste)\\" | sha512sum)\\" "
|
||||
"&& wl-copy -c", shell=True)
|
||||
run('wl-copy', stdin=Popen(('printf', '%b', _copy_subject.replace('\\\\\\', '\\\\\\\\\\\\\\')), stdout=PIPE).stdout)
|
||||
Popen(f"sleep 30; test \\'{_hash.hexdigest() + 2*' ' + '-'}\\' = \\"$(printf \\"$(wl-paste)\\" | sha512sum)\\" && wl-copy -c", shell=True)
|
||||
else:
|
||||
run(('xclip', '-sel', 'c'), stdin=Popen(('printf', _copy_subject
|
||||
.replace('\\\\\\', '\\\\\\\\\\\\\\').replace('%', '%%')), stdout=PIPE).stdout)
|
||||
Popen(f"sleep 30; test \\'{_hash.hexdigest() + 2*' ' + '-'}\\' = \\"$(printf \\"$(xclip -o -sel c)\\" | sha512sum)\\" "
|
||||
"&& xclip -i /dev/null -sel c", shell=True)"""
|
||||
run(('xclip', '-sel', 'c'), stdin=Popen(('printf', '%b', _copy_subject.replace('\\\\\\', '\\\\\\\\\\\\\\')), stdout=PIPE).stdout)
|
||||
Popen(f"sleep 30; test \\'{_hash.hexdigest() + 2*' ' + '-'}\\' = \\"$(printf \\"$(xclip -o -sel c)\\" | sha512sum)\\" && xclip -i /dev/null -sel c", shell=True)"""
|
||||
elif arguments[0] == 'BSD':
|
||||
replacement = """if 'WAYLAND_DISPLAY' in environ:
|
||||
run('wl-copy', stdin=Popen(('printf', _copy_subject
|
||||
.replace('\\\\\\', '\\\\\\\\\\\\\\').replace('%', '%%')), stdout=PIPE).stdout)
|
||||
Popen(f"sleep 30; test \\'{_hash.hexdigest() + 2*' ' + '-'}\\' = \\"$(printf \\"$(wl-paste)\\" | sha512sum)\\" "
|
||||
"&& wl-copy -c", shell=True)
|
||||
run('wl-copy', stdin=Popen(('printf', '%b', _copy_subject.replace('\\\\\\', '\\\\\\\\\\\\\\')), stdout=PIPE).stdout)
|
||||
Popen(f"sleep 30; test \\'{_hash.hexdigest() + 2*' ' + '-'}\\' = \\"$(printf \\"$(wl-paste)\\" | sha512sum)\\" && wl-copy -c", shell=True)
|
||||
else:
|
||||
run(('xclip', '-sel', 'c'), stdin=Popen(('printf', _copy_subject
|
||||
.replace('\\\\\\', '\\\\\\\\\\\\\\').replace('%', '%%')), stdout=PIPE).stdout)
|
||||
Popen(f"sleep 30; test \\'{_hash.hexdigest()}\\' = \\"$(printf \\"$(xclip -o -sel c)\\" | sha512sum)\\" "
|
||||
"&& xclip -i /dev/null -sel c", shell=True)"""
|
||||
run(('xclip', '-sel', 'c'), stdin=Popen(('printf', '%b', _copy_subject.replace('\\\\\\', '\\\\\\\\\\\\\\')), stdout=PIPE).stdout)
|
||||
Popen(f"sleep 30; test \\'{_hash.hexdigest()}\\' = \\"$(printf \\"$(xclip -o -sel c)\\" | sha512sum)\\" && xclip -i /dev/null -sel c", shell=True)"""
|
||||
else:
|
||||
s_exit()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user