From 8d9231ed33933e8db03da63ef64e33b5410711d3 Mon Sep 17 00:00:00 2001 From: reporter123 <84470+reporter123@users.noreply.github.com.> Date: Mon, 20 Jan 2025 19:09:58 -0500 Subject: [PATCH 1/2] fix: CHeck for escape sqeuences in quotes. --- dex | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/dex b/dex index 3af9c3a..0db0a79 100755 --- a/dex +++ b/dex @@ -393,7 +393,7 @@ class Application(DesktopEntry): ) @classmethod - def _build_cmd(cls, exec_string, needs_terminal=False, term="x-terminal-emulator"): + def _build_cmd(cls, exec_string:str, needs_terminal=False, term="x-terminal-emulator"): """ # test single and multi argument commands >>> Application._build_cmd('gvim') @@ -408,12 +408,12 @@ class Application(DesktopEntry): ['gvim test'] # test escape sequences - # >>> Application._build_cmd('"gvim test" test2 "test \\\\" 3"') - # ['gvim test', 'test2', 'test " 3'] - # >>> Application._build_cmd(r'"test \\\\\\\\ \\" moin" test') - # ['test \\\\ " moin', 'test'] - # >>> Application._build_cmd(r'"gvim \\\\\\\\ \\`test\\$"') - # ['gvim \\\\ \\`test\\$'] + >>> Application._build_cmd('"gvim test" test2 "test \\\\" 3"') + ['gvim test', 'test2', 'test " 3'] + >>> Application._build_cmd(r'"test \\\\\\\\ \\" moin" test') + ['test \\\\ " moin', 'test'] + >>> Application._build_cmd(r'"gvim \\\\\\\\ \\`test\\$"') + ['gvim \\\\ `test$'] >>> Application._build_cmd(r'vim ~/.vimrc', True) ['x-terminal-emulator', '-e', 'vim', '~/.vimrc'] >>> Application._build_cmd('vim ~/.vimrc', False) @@ -501,9 +501,8 @@ class Application(DesktopEntry): continue elif c == "\\": - if not in_quote: - in_esc = True - continue + in_esc = True + continue elif c == "%" and not (in_quote or in_singlequote): in_fieldcode = True @@ -880,6 +879,9 @@ def _property(args): return exit_value +a = Application._build_cmd('"gvim test" test2 "test \\\\" 3"') +sys.exit(0) + # start execution if __name__ == "__main__": from argparse import ArgumentParser From 343e01eb40ec3d54576d6d28744e06cf7e3b3868 Mon Sep 17 00:00:00 2001 From: reporter123 <84470+reporter123@users.noreply.github.com.> Date: Tue, 21 Jan 2025 10:11:02 -0500 Subject: [PATCH 2/2] rm debug code --- dex | 4 ---- 1 file changed, 4 deletions(-) diff --git a/dex b/dex index 0db0a79..1d978fa 100755 --- a/dex +++ b/dex @@ -878,10 +878,6 @@ def _property(args): print("Parse failed: %s%s%s" % (f, os.linesep, ex), file=sys.stderr) return exit_value - -a = Application._build_cmd('"gvim test" test2 "test \\\\" 3"') -sys.exit(0) - # start execution if __name__ == "__main__": from argparse import ArgumentParser