aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Rossi <alexandre.rossi@gmail.com>2019-07-04 15:09:38 +0200
committerAlexandre Rossi <alexandre.rossi@gmail.com>2019-07-04 15:09:38 +0200
commitc7d1d06b09e52f6d29eca4617d355623d62b5bf5 (patch)
tree9fb7d3b60e87915e2843164e800e94e827e7905c
parent625f516c36f982f1a8843b7fa474efcbad7c2f48 (diff)
downloadlazygal-c7d1d06b09e52f6d29eca4617d355623d62b5bf5.zip
lazygal-c7d1d06b09e52f6d29eca4617d355623d62b5bf5.tar.bz2
url_quote according to RFC 3986 (thanks Dominik Mierzejewski)
Closes https://bitbucket.org/niol/lazygal/issues/28/test_url_quote-fails-with-python-37
-rw-r--r--lazygal/pathutils.py3
-rw-r--r--lazygaltest/test_pathutils.py4
2 files changed, 4 insertions, 3 deletions
diff --git a/lazygal/pathutils.py b/lazygal/pathutils.py
index 4d27cd2..8daea32 100644
--- a/lazygal/pathutils.py
+++ b/lazygal/pathutils.py
@@ -100,7 +100,8 @@ def url_quote(url, anchor=''):
else:
toquote = url
- tokens.append(urlparse.quote(toquote.encode(sys.getfilesystemencoding())))
+ tokens.append(urlparse.quote(toquote.encode(sys.getfilesystemencoding()),
+ '/~'))
if anchor:
tokens.append('#')
diff --git a/lazygaltest/test_pathutils.py b/lazygaltest/test_pathutils.py
index 8dfd884..8b34d18 100644
--- a/lazygaltest/test_pathutils.py
+++ b/lazygaltest/test_pathutils.py
@@ -85,9 +85,9 @@ class TestPathutils(LazygalTest):
def test_url_quote(self):
self.assertEqual(url_quote('http://host:8080/~user/album/'),
- 'http://host:8080/%7Euser/album/')
+ 'http://host:8080/~user/album/')
self.assertEqual(url_quote('https://host/~user/album/'),
- 'https://host/%7Euser/album/')
+ 'https://host/~user/album/')
self.assertEqual(url_quote(u'/albumé/'), '/album%C3%A9/')
self.assertEqual(url_quote('filter: user/'), 'filter%3A%20user/')
self.assertEqual(url_quote('index.html', 'id'), 'index.html#id')