diff options
author | Florian Bruhin <me@the-compiler.org> | 2020-11-25 11:02:21 +0100 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2020-11-25 11:16:12 +0100 |
commit | dbade12432d5d64b3723b0e851d621df1498b0f9 (patch) | |
tree | 42593502ceaacbd3793c6744a7692f4c0abdad6a | |
parent | 84dc3a2b11ead12fd21743e46c304135f720c6cc (diff) | |
download | qutebrowser-dbade12432d5d64b3723b0e851d621df1498b0f9.tar.gz qutebrowser-dbade12432d5d64b3723b0e851d621df1498b0f9.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
(cherry picked from commit 49d92d463424fd56d3ebd9ff6ed6b44e6d0eb6d9)
-rw-r--r-- | qutebrowser/browser/navigate.py | 4 | ||||
-rw-r--r-- | tests/unit/browser/test_navigate.py | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/qutebrowser/browser/navigate.py b/qutebrowser/browser/navigate.py index ddc100d14..dbb2c1809 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' |