From 2696f9b4273d565f064075757e5e2b9a83be39ce Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Tue, 4 Oct 2016 07:36:49 -0400 Subject: [PATCH] Handle unicode characters in Completer. Just limit the cursor position to the length of the text to avoid crashes in this case. Resolves #2007. --- qutebrowser/completion/completer.py | 1 + tests/end2end/features/completion.feature | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/qutebrowser/completion/completer.py b/qutebrowser/completion/completer.py index 21f7b99ce..0c83a4976 100644 --- a/qutebrowser/completion/completer.py +++ b/qutebrowser/completion/completer.py @@ -157,6 +157,7 @@ class Completer(QObject): result = runner.parse(text, fallback=True, keep=True) parts = [x for x in result.cmdline if x] pos = self._cmd.cursorPosition() - len(self._cmd.prefix()) + pos = min(pos, len(text)) log.completion.debug('partitioning {} around position {}'.format(parts, pos)) for i, part in enumerate(parts): diff --git a/tests/end2end/features/completion.feature b/tests/end2end/features/completion.feature index 18f2141d8..4fec2d81b 100644 --- a/tests/end2end/features/completion.feature +++ b/tests/end2end/features/completion.feature @@ -22,3 +22,8 @@ Feature: Command bar completion # Make sure qutebrowser doesn't hang And I run :message-info "Still alive!" Then the message "Still alive!" should be shown + + Scenario: Crash when pasting emoji into the command line (#2007) + Given I open about:blank + When I run :set-cmd-text -s :🌀 + Then no crash should happen