From 6825dfb8d8706a14980f66ca7b3519a631d08c6f Mon Sep 17 00:00:00 2001 From: cryzed Date: Mon, 23 Apr 2018 19:01:12 +0200 Subject: [PATCH] qute-pass: Fake strings letter-by-letter to avoid issues --- misc/userscripts/qute-pass | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/misc/userscripts/qute-pass b/misc/userscripts/qute-pass index 4eddaf54c..fbe49a48a 100755 --- a/misc/userscripts/qute-pass +++ b/misc/userscripts/qute-pass @@ -109,6 +109,11 @@ def dmenu(items, invocation, encoding): return process.stdout.decode(encoding).strip() +def fake_key_raw(text): + for character in text: + qute_command(f'fake-key {character}') + + def main(arguments): if not arguments.url: argument_parser.print_help() @@ -150,7 +155,6 @@ def main(arguments): stderr('Failed to match username pattern on {}!'.format(arguments.username_target)) return ExitCodes.COULD_NOT_MATCH_USERNAME username = match.group(1) - username = username.replace('\\', '\\\\') # Match password match = re.match(arguments.password_pattern, secret) @@ -158,17 +162,20 @@ def main(arguments): stderr('Failed to match password pattern on secret!') return ExitCodes.COULD_NOT_MATCH_PASSWORD password = match.group(1) - password = password.replace('\\', '\\\\') - insert_mode = ';; enter-mode insert' if arguments.insert_mode else '' if arguments.username_only: - qute_command('fake-key {}{}'.format(username, insert_mode)) + fake_key_raw(username) elif arguments.password_only: - qute_command('fake-key {}{}'.format(password, insert_mode)) + fake_key_raw(password) else: # Enter username and password using fake-key and (which seems to work almost universally), then switch # back into insert-mode, so the form can be directly submitted by hitting enter afterwards - qute_command('fake-key {} ;; fake-key ;; fake-key {}{}'.format(username, password, insert_mode)) + fake_key_raw(username) + qute_command('fake-key ') + fake_key_raw(password) + + if arguments.insert_mode: + qute_command('enter-mode insert') return ExitCodes.SUCCESS