Permalink
Browse files

No longer quote pluses in URL parts by the routing system. This fixes #…

  • Loading branch information...
1 parent 7dc8959 commit 88c715aad9cf288c19afb29be6122ff7f29455b7 @mitsuhiko mitsuhiko committed Dec 27, 2011
Showing with 20 additions and 4 deletions.
  1. +2 −0 CHANGES
  2. +4 −3 werkzeug/routing.py
  3. +14 −1 werkzeug/testsuite/routing.py
View
@@ -18,6 +18,8 @@ Relase date to be decided, codename to be chosen.
- :func:`werkzeug.wsgi.make_chunk_iter` and
:func:`werkzeug.wsgi.make_line_iter` now support processing of
iterators and streams.
+- URL generation by the routing system now no longer quotes
+ ``+``.
Version 0.8.3
-------------
View
@@ -100,7 +100,7 @@
from pprint import pformat
from urlparse import urljoin
-from werkzeug.urls import url_encode, url_decode, url_quote
+from werkzeug.urls import url_encode, url_quote
from werkzeug.utils import redirect, format_string
from werkzeug.exceptions import HTTPException, NotFound, MethodNotAllowed
from werkzeug._internal import _get_environ
@@ -715,7 +715,7 @@ def build(self, values, append_unknown=True):
return
processed.add(data)
else:
- add(url_quote(data, self.map.charset, safe='/:|'))
+ add(url_quote(data, self.map.charset, safe='/:|+'))
domain_part, url = (u''.join(tmp)).split('|', 1)
if append_unknown:
@@ -1503,7 +1503,8 @@ def make_redirect_url(self, path_info, query_args=None, domain_part=None):
self.url_scheme,
self.get_host(domain_part),
posixpath.join(self.script_name[:-1].lstrip('/'),
- url_quote(path_info.lstrip('/'), self.map.charset)),
+ url_quote(path_info.lstrip('/'), self.map.charset,
+ safe='/:|+')),
suffix
))
@@ -611,7 +611,8 @@ def test_redirect_request_exception_code(self):
def test_unicode_rules(self):
m = r.Map([
- r.Rule(u'/войти/', endpoint='enter')
+ r.Rule(u'/войти/', endpoint='enter'),
+ r.Rule(u'/foo+bar/', endpoint='foobar')
])
a = m.bind(u'☃.example.com')
try:
@@ -623,9 +624,21 @@ def test_unicode_rules(self):
self.assert_equal(endpoint, 'enter')
self.assert_equal(values, {})
+ try:
+ a.match(u'/foo+bar')
+ except r.RequestRedirect, e:
+ self.assert_equal(e.new_url, 'http://xn--n3h.example.com/'
+ 'foo+bar/')
+ endpoint, values = a.match(u'/foo+bar/')
+ self.assert_equal(endpoint, 'foobar')
+ self.assert_equal(values, {})
+
url = a.build('enter', {}, force_external=True)
self.assert_equal(url, 'http://xn--n3h.example.com/%D0%B2%D0%BE%D0%B9%D1%82%D0%B8/')
+ url = a.build('foobar', {}, force_external=True)
+ self.assert_equal(url, 'http://xn--n3h.example.com/foo+bar/')
+
def suite():
suite = unittest.TestSuite()

0 comments on commit 88c715a

Please sign in to comment.