From 0f3aa0bd8c4519411293925416e87feec4404399 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 7 Aug 2015 17:21:18 +0200 Subject: [PATCH] Ctrl-A only increments number in path segment This prevents a host like "myfoo42.bar" changing to "myfoo43.bar" when pressing Ctrl-A. It further prevents increasing the port number, e.g. going from "foo.bar:8080" to "foo.bar:8081". --- qutebrowser/browser/commands.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index ff117ca38..057b54a24 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -472,9 +472,9 @@ class CommandDispatcher: background: Open the link in a new background tab. window: Open the link in a new window. """ - encoded = bytes(url.toEncoded()).decode('ascii') + path = url.path() # Get the last number in a string - match = re.match(r'(.*\D|^)(\d+)(.*)', encoded) + match = re.match(r'(.*\D|^)(\d+)(.*)', path) if not match: raise cmdexc.CommandError("No number found in URL!") pre, number, post = match.groups() @@ -493,8 +493,10 @@ class CommandDispatcher: val += 1 else: raise ValueError("Invalid value {} for indec!".format(incdec)) - urlstr = ''.join([pre, str(val), post]).encode('ascii') - new_url = QUrl.fromEncoded(urlstr) + new_path = ''.join([pre, str(val), post]) + # Make a copy of the QUrl so we don't modify the original + new_url = QUrl(url) + new_url.setPath(new_path) self._open(new_url, tab, background, window) def _navigate_up(self, url, tab, background, window):