diff options
| author | Chris McDonough <chrism@plope.com> | 2012-01-19 20:36:45 -0500 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2012-01-19 20:36:45 -0500 |
| commit | 05f462e9792d9b5f6560968503795dc162984408 (patch) | |
| tree | d8efb500a65bf86d73d7e1dcd598103451d6d070 | |
| parent | 134388a0157728b1f96daa09fb8bdfde6a1de209 (diff) | |
| download | pyramid-05f462e9792d9b5f6560968503795dc162984408.tar.gz pyramid-05f462e9792d9b5f6560968503795dc162984408.tar.bz2 pyramid-05f462e9792d9b5f6560968503795dc162984408.zip | |
Backport fix for issue #407 to 1.3 branch.
| -rw-r--r-- | CHANGES.txt | 3 | ||||
| -rw-r--r-- | pyramid/config/views.py | 3 | ||||
| -rw-r--r-- | pyramid/tests/test_config/test_views.py | 16 |
3 files changed, 19 insertions, 3 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index bfafaaae3..c1b6ae976 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -26,6 +26,9 @@ Bug Fixes decorator, the view defaults would not be applied. See https://github.com/Pylons/pyramid/issues/396 . +- Static URL paths were URL-quoted twice. See + https://github.com/Pylons/pyramid/issues/407 . + 1.3a5 (2012-01-09) ================== diff --git a/pyramid/config/views.py b/pyramid/config/views.py index 8d7885bd2..0359c46f7 100644 --- a/pyramid/config/views.py +++ b/pyramid/config/views.py @@ -1545,11 +1545,12 @@ class StaticURLInfo(object): registry = get_current_registry() for (url, spec, route_name) in self._get_registrations(registry): if path.startswith(spec): - subpath = url_quote(path[len(spec):]) + subpath = path[len(spec):] if url is None: kw['subpath'] = subpath return request.route_url(route_name, **kw) else: + subpath = url_quote(subpath) return urljoin(url, subpath) raise ValueError('No static URL definition matching %s' % path) diff --git a/pyramid/tests/test_config/test_views.py b/pyramid/tests/test_config/test_views.py index aa941c0cf..4af29325a 100644 --- a/pyramid/tests/test_config/test_views.py +++ b/pyramid/tests/test_config/test_views.py @@ -3542,6 +3542,18 @@ class TestStaticURLInfo(unittest.TestCase): result = inst.generate('package:path/', request) self.assertEqual(result, 'http://example.com/foo/') + def test_generate_quoting(self): + config = testing.setUp() + try: + config.add_static_view('images', path='mypkg:templates') + inst = self._makeOne() + request = testing.DummyRequest() + request.registry = config.registry + result = inst.generate('mypkg:templates/foo%2Fbar', request) + self.assertEqual(result, 'http://example.com/images/foo%252Fbar') + finally: + testing.tearDown() + def test_generate_route_url(self): inst = self._makeOne() registrations = [(None, 'package:path/', '__viewname/')] @@ -3555,13 +3567,13 @@ class TestStaticURLInfo(unittest.TestCase): result = inst.generate('package:path/abc', request, a=1) self.assertEqual(result, 'url') - def test_generate_url_quoted_local(self): + def test_generate_url_unquoted_local(self): inst = self._makeOne() registrations = [(None, 'package:path/', '__viewname/')] inst._get_registrations = lambda *x: registrations def route_url(n, **kw): self.assertEqual(n, '__viewname/') - self.assertEqual(kw, {'subpath':'abc%20def', 'a':1}) + self.assertEqual(kw, {'subpath':'abc def', 'a':1}) return 'url' request = self._makeRequest() request.route_url = route_url |
