From adffed9273ee680750de8985506b4227c50033bc Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Thu, 6 Apr 2017 18:29:06 -0400 Subject: [PATCH] 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 --- heat/engine/hot/functions.py | 2 +- heat/tests/test_hot.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/heat/engine/hot/functions.py b/heat/engine/hot/functions.py index b84dc0e53c..c4bd92c1d0 100644 --- a/heat/engine/hot/functions.py +++ b/heat/engine/hot/functions.py @@ -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, '')) diff --git a/heat/tests/test_hot.py b/heat/tests/test_hot.py index ec79974161..74f5a4dadb 100644 --- a/heat/tests/test_hot.py +++ b/heat/tests/test_hot.py @@ -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 = {