summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2019-07-18 09:48:05 +0200
committerFlorian Bruhin <me@the-compiler.org>2019-07-18 09:48:05 +0200
commit06ff46ad98cf1a81d300eb4da97464fc4f162d3d (patch)
tree554934e9ccb9163dfe89fb1a00f30c91553e5e7a
parentea45eb126165a65605275a09d4783e4e467d3018 (diff)
downloadqutebrowser-06ff46ad98cf1a81d300eb4da97464fc4f162d3d.tar.gz
qutebrowser-06ff46ad98cf1a81d300eb4da97464fc4f162d3d.zip
Use FullyEncoded to get URL segments
See #4917, #4795
-rw-r--r--qutebrowser/utils/urlutils.py8
-rw-r--r--tests/unit/utils/test_urlutils.py9
2 files changed, 12 insertions, 5 deletions
diff --git a/qutebrowser/utils/urlutils.py b/qutebrowser/utils/urlutils.py
index a9b68852c..e639bd34e 100644
--- a/qutebrowser/utils/urlutils.py
+++ b/qutebrowser/utils/urlutils.py
@@ -558,7 +558,7 @@ def _get_incdec_value(match, incdec, url, count):
# of information. (host and path use FullyDecoded by default)
_URL_SEGMENTS = [
('host',
- lambda url: url.host(QUrl.PrettyDecoded),
+ lambda url: url.host(QUrl.FullyEncoded),
lambda url, host: url.setHost(host, QUrl.StrictMode)),
('port',
@@ -566,15 +566,15 @@ _URL_SEGMENTS = [
lambda url, x: url.setPort(int(x))),
('path',
- lambda url: url.path(QUrl.PrettyDecoded),
+ lambda url: url.path(QUrl.FullyEncoded),
lambda url, path: url.setPath(path, QUrl.StrictMode)),
('query',
- lambda url: url.query(QUrl.PrettyDecoded),
+ lambda url: url.query(QUrl.FullyEncoded),
lambda url, query: url.setQuery(query, QUrl.StrictMode)),
('anchor',
- lambda url: url.fragment(QUrl.PrettyDecoded),
+ lambda url: url.fragment(QUrl.FullyEncoded),
lambda url, fragment: url.setFragment(fragment, QUrl.StrictMode)),
]
diff --git a/tests/unit/utils/test_urlutils.py b/tests/unit/utils/test_urlutils.py
index 2c6478b32..9499c3b1d 100644
--- a/tests/unit/utils/test_urlutils.py
+++ b/tests/unit/utils/test_urlutils.py
@@ -636,9 +636,16 @@ class TestIncDecNumber:
'http://localhost/?v=:{}',
'http://localhost/#%3A{}',
'http://localhost/#:{}',
+
+ # Make sure that spaces in paths work
+ 'http://example.com/path with {} spaces',
])
def test_incdec_number(self, incdec, value, url):
"""Test incdec_number with valid URLs."""
+ if (value == '{}foo' and
+ url == 'http://example.com/path with {} spaces'):
+ pytest.xfail("https://github.com/qutebrowser/qutebrowser/issues/4917")
+
# The integer used should not affect test output, as long as it's
# bigger than 1
# 20 was chosen by dice roll, guaranteed to be random
@@ -679,7 +686,7 @@ class TestIncDecNumber:
'http://example.com:80/v1/query_test?value={}',
'http://example.com:80/v1/anchor_test#{}',
'http://host_{}_test.com:80',
- 'http://m4ny.c0m:80/number5/3very?where=yes#{}'
+ 'http://m4ny.c0m:80/number5/3very?where=yes#{}',
])
@pytest.mark.parametrize('count', [1, 5, 100])
def test_incdec_number_count(self, incdec, value, url, count):