Permalink
Browse files

revert my reversion

  • Loading branch information...
1 parent ea3cd10 commit ca419fb59ccf2174a87aba5139a293b807e15df6 @mcdonc mcdonc committed Nov 27, 2013
Showing with 19 additions and 17 deletions.
  1. +5 −5 CHANGES.txt
  2. +14 −12 pyramid/url.py
View
@@ -50,7 +50,7 @@ Features
- The anchor argument to ``pyramid.request.Request.route_url`` and
``pyramid.request.Request.resource_url`` and their derivatives will now be
- escaped to ensure minimal conformance. See
+ escaped via URL quoting to ensure minimal conformance. See
https://github.com/Pylons/pyramid/pull/1183
- Allow sending of ``_query`` and ``_anchor`` options to
@@ -61,10 +61,10 @@ Features
- You can now send a string as the ``_query`` argument to
``pyramid.request.Request.route_url`` and
``pyramid.request.Request.resource_url`` and their derivatives. When a
- string is sent instead of a list or dictionary. it is not URL-encoded or
- quoted; the caller must perform this job before passing it in. This is
- useful if you want to be able to use a different query string format than
- ``x-www-form-urlencoded``. See https://github.com/Pylons/pyramid/pull/1183
+ string is sent instead of a list or dictionary. it is URL-quoted however it
+ does not need to be in ``k=v`` form. This is useful if you want to be able
+ to use a different query string format than ``x-www-form-urlencoded``. See
+ https://github.com/Pylons/pyramid/pull/1183
Bug Fixes
---------
View
@@ -48,7 +48,7 @@ def parse_url_overrides(kw):
if '_query' in kw:
query = kw.pop('_query')
if isinstance(query, string_types):
- qs = '?' + query
+ qs = '?' + url_quote(query, QUERY_SAFE)
elif query:
qs = '?' + urlencode(query, doseq=True)
@@ -176,12 +176,13 @@ def route_url(self, route_name, *elements, **kw):
This data structure will be turned into a query string per the
documentation of :func:`pyramid.url.urlencode` function. This will
produce a query string in the ``x-www-form-urlencoded`` format. A
- non-``x-www-form-urlencoded`` encoding may be used by passing a
- *string* value as ``_query`` in which case it will be used without
- quoting or encoding; it is left up to the caller to do both and if he
- does not, an invalid URL may be generated. After the query data is
- turned into a query string, a leading ``?`` is prepended, and the
- resulting string is appended to the generated URL.
+ non-``x-www-form-urlencoded`` query string may be used by passing a
+ *string* value as ``_query`` in which case it will be URL-quoted
+ (e.g. query="foo bar" will become "foo%20bar"). However, the result
+ will not need to be in ``k=v`` form as required by
+ ``x-www-form-urlencoded``. After the query data is turned into a query
+ string, a leading ``?`` is prepended, and the resulting string is
+ appended to the generated URL.
.. note::
@@ -369,10 +370,11 @@ def resource_url(self, resource, *elements, **kw):
function. This will produce a query string in the
``x-www-form-urlencoded`` encoding. A non-``x-www-form-urlencoded``
query string may be used by passing a *string* value as ``query`` in
- which case it will be used without quoting or encoding; it is up to the
- caller to do both and if he does not an invalid URL may be generated.
- After the query data is turned into a query string, a leading ``?`` is
- prepended, and the resulting string is appended to the generated URL.
+ which case it will be URL-quoted (e.g. query="foo bar" will become
+ "foo%20bar"). However, the result will not need to be in ``k=v`` form
+ as required by ``x-www-form-urlencoded``. After the query data is
+ turned into a query string, a leading ``?`` is prepended, and the
+ resulting string is appended to the generated URL.
.. note::
@@ -619,7 +621,7 @@ def resource_url(self, resource, *elements, **kw):
if 'query' in kw:
query = kw['query']
if isinstance(query, string_types):
- qs = '?' + query
+ qs = '?' + url_quote(query, QUERY_SAFE)
elif query:
qs = '?' + urlencode(query, doseq=True)

0 comments on commit ca419fb

Please sign in to comment.