Commit a6b17ed5 authored by Laurent Bachelier's avatar Laurent Bachelier

Fix escaping when ':' are in filenames

parent 98c5671d
......@@ -30,6 +30,7 @@ UNSAFE_CHARS = {
'?': quote('?'),
'&': quote('&'),
';': quote(';'),
':': quote(':'),
',': quote(','),
'=': quote('='),
' ': quote(' '),
......@@ -60,7 +61,7 @@ def quote_url(url):
"""
purl = urlsplit(url.url)
# do not escape the scheme and netloc
if purl.scheme or purl.netloc:
if purl.scheme and purl.netloc:
path = urlunsplit((None, None, purl.path, purl.query, purl.fragment))
basepath = urlunsplit((purl.scheme, purl.netloc, '', None, None))
else:
......
from ass2m.filters import quote_url
from paste.url import URL
from unittest import TestCase
class FiltersTest(TestCase):
def test_quote(self):
assert quote_url(URL('http://ass2m.org/')) \
== 'http://ass2m.org/'
assert quote_url(URL('http://ass2m.org:42/')) \
== 'http://ass2m.org:42/'
assert quote_url(URL('22:42:01.JPG').setvars(view='thumbnail')) \
== '22%3A42%3A01.JPG?view=thumbnail'
assert quote_url(URL('http://ass2m.org/22:42:01.JPG').setvars(view='thumbnail')) \
== 'http://ass2m.org/22%3A42%3A01.JPG?view=thumbnail'
assert quote_url(URL('http://ass2m.org:42/22:42:01.JPG').setvars(view='thumbnail')) \
== 'http://ass2m.org:42/22%3A42%3A01.JPG?view=thumbnail'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment