Skip to content
Myr

Escape slashes in query strings. This fixes #445

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 0bfb60f · Browse files · 3 files+10 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+10 added−3 removed

  • other:+10 added−3 removed

3 files+10 added−3 removed

modified:jinja2/filters.py+2 added-1 removed
92 unmodified lines
93 pass94 if itemiter is None:95 return unicode_urlencode(value)96 return u'&'.join(unicode_urlencode(k) + '=' +97 unicode_urlencode(v) for k, v in itemiter)97 unicode_urlencode(v, for_qs=True)98 for k, v in itemiter)99100101@evalcontextfilter102def do_replace(eval_ctx, s, old, new, count=None):
893 unmodified lines
modified:jinja2/utils.py+6 added-2 removed
281 unmodified lines
282 return u'\n\n'.join(result)283 return Markup(u'\n'.join(u'<p>%s</p>' % escape(x) for x in result))284285286def unicode_urlencode(obj, charset='utf-8'):286def unicode_urlencode(obj, charset='utf-8', for_qs=False):287 """URL escapes a single bytestring or unicode string with the288 given charset if applicable to URL safe quoting under all rules289 that need to be considered under all supported Python versions.290
3 unmodified lines
294 if not isinstance(obj, string_types):295 obj = text_type(obj)296 if isinstance(obj, text_type):297 obj = obj.encode(charset)298 return text_type(url_quote(obj))298 safe = for_qs and b'' or b'/'299 rv = text_type(url_quote(obj, safe))300 if for_qs:301 rv = rv.replace('%20', '+')302 return rv303304305class LRUCache(object):306 """A simple LRU Cache implementation."""
225 unmodified lines
modified:CHANGES+2 added
29 unmodified lines
30 ``jinja2.runtime.Context`` by adding two new attributes to the environment31 (`code_generator_class` and `context_class`) (pull request ``#404``).32- added support for context/environment/evalctx decorator functions on33 the finalize callback of the environment.34- escape query strings for urlencode properly. Previously slashes were not35 escaped in that place.3637Version 2.7.338-------------39(bugfix release, released on June 6th 2014)
328 unmodified lines