Don't escape /s in make_url query strings

Query strings are not _required_ to have slashes escaped, and in fact RFC
3986 suggests that "it is sometimes better for usability to avoid
percent-escaping those characters" (Section 3.4).

TripleO is currently unable to use the make_url function because its
database URLs contain slashes in the query, and end up in config files that
don't allow percent characters. This is probably not going to be an
isolated occurrence, so don't escape slashes in the query string.

Change-Id: I72f84e737b042ecfaabf5639c6164d46a072b423
This commit is contained in:
Zane Bitter 2017-04-06 18:29:06 -04:00
parent 418dbbd1fa
commit adffed9273
2 changed files with 5 additions and 5 deletions

View File

@ -1430,7 +1430,7 @@ class MakeURL(function.Function):
path = urlparse.quote(args.get(self.PATH, ''))
query_dict = args.get(self.QUERY, {})
query = urlparse.urlencode(query_dict)
query = urlparse.urlencode(query_dict).replace('%2F', '/')
fragment = urlparse.quote(args.get(self.FRAGMENT, ''))

View File

@ -1964,8 +1964,8 @@ conditions:
'host': 'example.com',
'path': '/foo/?bar',
'query': {
'foo': 'bar&baz',
'blarg': 'wib=ble',
'foo#': 'bar & baz',
'blarg': '/wib=ble/',
},
}
}
@ -1974,9 +1974,9 @@ conditions:
self.assertIn(resolved,
['http://example.com/foo/%3Fbar'
'?foo=bar%26baz&blarg=wib%3Dble',
'?foo%23=bar+%26+baz&blarg=/wib%3Dble/',
'http://example.com/foo/%3Fbar'
'?blarg=wib%3Dble&foo=bar%26baz'])
'?blarg=/wib%3Dble/&foo%23=bar+%26+baz'])
def test_make_url_fragment(self):
snippet = {