Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
request.static_url quotes paths twice #407
When generating a static URL the path is encoded twice. Here is an example:
>>> import pyramid.testing >>> config = pyramid.testing.setUp() >>> config.add_static_view('images', path='mypkg:templates') >>> request=pyramid.testing.DummyRequest() >>> request.static_url('mypkg:templates/one%2Ftwo') 'http://example.com/images/one%25252Ftwo'
Looking at pyramid code the first quoting happens inside StaticURLInfo.generate:
if path.startswith(spec): subpath = urllib.quote(path[len(spec):]) if url is None: kw['subpath'] = subpath return request.route_url(route_name, **kw) else: return urljoin(url, subpath)
and the again when StaticURLInfo calls route_url, which uses quote_path_segment again:
# a stararg argument if hasattr(v, '__iter__'): v = '/'.join([quote_path_segment(x) for x in v]) # native
I suspect that the right fix here is to remove the quoting done in StaticURLInfo and rely on route_url to quote paths correctly.