Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Renamed urlescape to urlencode

  • Loading branch information...
commit 5145401fe5f9995a32757f34359623b87048ab8b 1 parent 1d4c638
@mitsuhiko authored
View
2  CHANGES
@@ -10,7 +10,7 @@ Version 2.7
advertised.
- Fixed filesizeformat.
- Added a non-silent option for babel extraction.
-- Added `urlescape` filter that automatically quotes values for
+- Added `urlencode` filter that automatically quotes values for
URL safe usage with utf-8 as only supported encoding. If applications
want to change this encoding they can override the filter.
View
12 jinja2/filters.py
@@ -14,7 +14,7 @@
from operator import itemgetter
from itertools import imap, groupby
from jinja2.utils import Markup, escape, pformat, urlize, soft_unicode, \
- unicode_urlescape
+ unicode_urlencode
from jinja2.runtime import Undefined
from jinja2.exceptions import FilterArgumentError
@@ -71,7 +71,7 @@ def do_forceescape(value):
return escape(unicode(value))
-def do_urlescape(value):
+def do_urlencode(value):
"""Escape strings for use in URLs (uses UTF-8 encoding). It accepts both
@jparise
jparise added a note

Perhaps s/Escape/Encode/ here, as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
dictionaries and regular strings as well as pairwise iterables.
@@ -86,9 +86,9 @@ def do_urlescape(value):
except TypeError:
pass
if itemiter is None:
- return unicode_urlescape(value)
- return u'&'.join(unicode_urlescape(k) + '=' +
- unicode_urlescape(v) for k, v in itemiter)
+ return unicode_urlencode(value)
+ return u'&'.join(unicode_urlencode(k) + '=' +
+ unicode_urlencode(v) for k, v in itemiter)
@evalcontextfilter
@@ -819,5 +819,5 @@ def do_attr(environment, obj, name):
'groupby': do_groupby,
'safe': do_mark_safe,
'xmlattr': do_xmlattr,
- 'urlescape': do_urlescape
+ 'urlencode': do_urlencode
}
View
6 jinja2/testsuite/filters.py
@@ -367,11 +367,11 @@ def test_safe(self):
tmpl = env.from_string('{{ "<div>foo</div>" }}')
assert tmpl.render() == '&lt;div&gt;foo&lt;/div&gt;'
- def test_urlescape(self):
+ def test_urlencode(self):
env = Environment(autoescape=True)
- tmpl = env.from_string('{{ "Hello, world!"|urlescape }}')
+ tmpl = env.from_string('{{ "Hello, world!"|urlencode }}')
assert tmpl.render() == 'Hello%2C%20world%21'
- tmpl = env.from_string('{{ o|urlescape }}')
+ tmpl = env.from_string('{{ o|urlencode }}')
assert tmpl.render(o=u"Hello, world\u203d") == "Hello%2C%20world%E2%80%BD"
assert tmpl.render(o=(("f", 1),)) == "f=1"
assert tmpl.render(o=(('f', 1), ("z", 2))) == "f=1&amp;z=2"
View
2  jinja2/utils.py
@@ -353,7 +353,7 @@ def generate_lorem_ipsum(n=5, html=True, min=20, max=100):
return Markup(u'\n'.join(u'<p>%s</p>' % escape(x) for x in result))
-def unicode_urlescape(obj, charset='utf-8'):
+def unicode_urlencode(obj, charset='utf-8'):
"""URL escapes a single bytestring or unicode string with the
given charset if applicable to URL safe quoting under all rules
that need to be considered under all supported Python versions.
Please sign in to comment.
Something went wrong with that request. Please try again.