diff --git a/qutebrowser/completion/completer.py b/qutebrowser/completion/completer.py index 83e4e6fc2..c6a2643fb 100644 --- a/qutebrowser/completion/completer.py +++ b/qutebrowser/completion/completer.py @@ -111,7 +111,7 @@ class Completer(QObject): """ if not s: return "''" - elif any(c in s for c in ' \'\t\n\\'): + elif any(c in s for c in ' "\'\t\n\\'): # use single quotes, and put single quotes into double quotes # the string $'b is then quoted as '$'"'"'b' return "'" + s.replace("'", "'\"'\"'") + "'" diff --git a/tests/unit/completion/test_completer.py b/tests/unit/completion/test_completer.py index e8667ec22..8914a956b 100644 --- a/tests/unit/completion/test_completer.py +++ b/tests/unit/completion/test_completer.py @@ -240,6 +240,10 @@ def test_update_completion(txt, kind, pattern, pos_args, status_command_stub, ":set fonts hints '12px Hack'|"), (":set fonts hints 'Comic| Sans'", '12px Hack', ":set fonts hints '12px Hack'|"), + # Make sure " is quoted properly + (':set url.start_pages \'["https://www.|example.com"]\'', + '["https://www.example.org"]', + ':set url.start_pages \'["https://www.example.org"]\'|'), # open has maxsplit=0, so treat the last two tokens as one and don't quote (':open foo bar|', 'baz', ':open baz|'), (':open foo| bar', 'baz', ':open baz|'),