summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2013-08-28 03:39:02 -0400
committerChris McDonough <chrism@plope.com>2013-08-28 03:39:02 -0400
commit58951c0a9a4fc2a2122d88170b0761b1d89ea91c (patch)
treefe2aac9059f19cac92f42a63f048eab59ffc92c2
parent001c232fcfe7377b7b0e2d03dcbe68c7b7db0363 (diff)
downloadpyramid-58951c0a9a4fc2a2122d88170b0761b1d89ea91c.tar.gz
pyramid-58951c0a9a4fc2a2122d88170b0761b1d89ea91c.tar.bz2
pyramid-58951c0a9a4fc2a2122d88170b0761b1d89ea91c.zip
- The ``route_url`` and ``route_path`` APIs no longer quote ``/``
to ``%2F`` when a replacement value contains a ``/``. This was pointless, as WSGI servers always unquote the slash anyway, and Pyramid never sees the quoted value.
-rw-r--r--CHANGES.txt5
-rw-r--r--pyramid/tests/test_urldispatch.py10
-rw-r--r--pyramid/urldispatch.py6
3 files changed, 14 insertions, 7 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 0db274a19..a527f7c1e 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -207,6 +207,11 @@ Backwards Incompatibilities
previously returned the URL without the query string by default, it now does
attach the query string unless it is overriden.
+- The ``route_url`` and ``route_path`` APIs no longer quote ``/``
+ to ``%2F`` when a replacement value contains a ``/``. This was pointless,
+ as WSGI servers always unquote the slash anyway, and Pyramid never sees the
+ quoted value.
+
1.4 (2012-12-18)
================
diff --git a/pyramid/tests/test_urldispatch.py b/pyramid/tests/test_urldispatch.py
index b2164717e..1755d9f47 100644
--- a/pyramid/tests/test_urldispatch.py
+++ b/pyramid/tests/test_urldispatch.py
@@ -295,7 +295,7 @@ class TestCompileRoute(unittest.TestCase):
'remainder':'/everything/else/here'})
self.assertEqual(matcher('foo/baz/biz/buz/bar'), None)
self.assertEqual(generator(
- {'baz':1, 'buz':2, 'remainder':'/a/b'}), '/foo/1/biz/2/bar%2Fa%2Fb')
+ {'baz':1, 'buz':2, 'remainder':'/a/b'}), '/foo/1/biz/2/bar/a/b')
def test_no_beginning_slash(self):
matcher, generator = self._callFUT('foo/:baz/biz/:buz/bar')
@@ -491,10 +491,10 @@ class TestCompileRouteFunctional(unittest.TestCase):
self.generates('zzz/{x}*traverse', {'x':'abc', 'traverse':'/def/g'},
'/zzz/abc/def/g')
self.generates('/{x}', {'x':text_(b'/La Pe\xc3\xb1a', 'utf-8')},
- '/%2FLa%20Pe%C3%B1a')
+ '//La%20Pe%C3%B1a')
self.generates('/{x}*y', {'x':text_(b'/La Pe\xc3\xb1a', 'utf-8'),
'y':'/rest/of/path'},
- '/%2FLa%20Pe%C3%B1a/rest/of/path')
+ '//La%20Pe%C3%B1a/rest/of/path')
self.generates('*traverse', {'traverse':('a', text_(b'La Pe\xf1a'))},
'/a/La%20Pe%C3%B1a')
self.generates('/foo/{id}.html', {'id':'bar'}, '/foo/bar.html')
@@ -511,10 +511,10 @@ class TestCompileRouteFunctional(unittest.TestCase):
self.generates('zzz/:x*traverse', {'x':'abc', 'traverse':'/def/g'},
'/zzz/abc/def/g')
self.generates('/:x', {'x':text_(b'/La Pe\xc3\xb1a', 'utf-8')},
- '/%2FLa%20Pe%C3%B1a')
+ '//La%20Pe%C3%B1a')
self.generates('/:x*y', {'x':text_(b'/La Pe\xc3\xb1a', 'utf-8'),
'y':'/rest/of/path'},
- '/%2FLa%20Pe%C3%B1a/rest/of/path')
+ '//La%20Pe%C3%B1a/rest/of/path')
self.generates('*traverse', {'traverse':('a', text_(b'La Pe\xf1a'))},
'/a/La%20Pe%C3%B1a')
self.generates('/foo/:id.html', {'id':'bar'}, '/foo/bar.html')
diff --git a/pyramid/urldispatch.py b/pyramid/urldispatch.py
index 4182ea665..8090f07f2 100644
--- a/pyramid/urldispatch.py
+++ b/pyramid/urldispatch.py
@@ -213,7 +213,9 @@ def _compile_route(route):
if k == remainder:
# a stararg argument
if is_nonstr_iter(v):
- v = '/'.join([quote_path_segment(x) for x in v]) # native
+ v = '/'.join(
+ [quote_path_segment(x, safe='/') for x in v]
+ ) # native
else:
if v.__class__ not in string_types:
v = str(v)
@@ -222,7 +224,7 @@ def _compile_route(route):
if v.__class__ not in string_types:
v = str(v)
# v may be bytes (py2) or native string (py3)
- v = quote_path_segment(v)
+ v = quote_path_segment(v, safe='/')
# at this point, the value will be a native string
newdict[k] = v