summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2020-11-25 11:02:21 +0100
committerFlorian Bruhin <me@the-compiler.org>2020-11-25 11:04:16 +0100
commit49d92d463424fd56d3ebd9ff6ed6b44e6d0eb6d9 (patch)
treec4514fbd9d74af3e39d9a98b7e86452fa630bb87
parentba152cbe4ab3c97110a21df02ee858dcc8c8f14b (diff)
downloadqutebrowser-49d92d463424fd56d3ebd9ff6ed6b44e6d0eb6d9.tar.gz
qutebrowser-49d92d463424fd56d3ebd9ff6ed6b44e6d0eb6d9.zip
Don't percent-decode path with ":navigate up"
If we have an URL with e.g. %2F in the path, we shouldn't treat that as separator, and it shouldn't be converted to a "/". Fixes #5908
-rw-r--r--qutebrowser/browser/navigate.py4
-rw-r--r--tests/unit/browser/test_navigate.py2
2 files changed, 4 insertions, 2 deletions
diff --git a/qutebrowser/browser/navigate.py b/qutebrowser/browser/navigate.py
index b852ab29e..bace6fa6a 100644
--- a/qutebrowser/browser/navigate.py
+++ b/qutebrowser/browser/navigate.py
@@ -134,13 +134,13 @@ def path_up(url, count):
"""
urlutils.ensure_valid(url)
url = url.adjusted(QUrl.RemoveFragment | QUrl.RemoveQuery)
- path = url.path()
+ path = url.path(QUrl.FullyEncoded)
if not path or path == '/':
raise Error("Can't go up!")
for _i in range(0, min(count, path.count('/'))):
path = posixpath.join(path, posixpath.pardir)
path = posixpath.normpath(path)
- url.setPath(path)
+ url.setPath(path, QUrl.StrictMode)
return url
diff --git a/tests/unit/browser/test_navigate.py b/tests/unit/browser/test_navigate.py
index 5fe0acbf6..5a93a517c 100644
--- a/tests/unit/browser/test_navigate.py
+++ b/tests/unit/browser/test_navigate.py
@@ -187,6 +187,8 @@ class TestUp:
('/one/two/three', 1, '/one/two'),
('/one/two/three?foo=bar', 1, '/one/two'),
('/one/two/three', 2, '/one'),
+ ('/one/two%2Fthree', 1, '/one'),
+ ('/one/two%2Fthree/four', 1, '/one/two%2Fthree'),
])
def test_up(self, url_suffix, count, expected_suffix):
url_base = 'https://example.com'