Skip to content
Myr

live up to @mitsuhiko's ridiculous expectations

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

authored by Aaron Swartz · committed by Aaron Swartz · parent 06a8b1c · Browse files · 2 files+24 added−7 removed
This commit

State

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

Diff stats

2 files+24 added−7 removed

  • other:+24 added−7 removed

2 files+24 added−7 removed

modified:jinja2/testsuite/filters.py+7 added-1 removed
367 unmodified lines
368 assert tmpl.render() == '<div>foo</div>'369 370 def test_urlescape(self):371 env = Environment(autoescape=True)372 tmpl = env.from_string('{{ "Hello, world!"|urle }}')372 tmpl = env.from_string('{{ "Hello, world!"|urlescape }}')373 assert tmpl.render() == 'Hello%2C%20world%21'374 tmpl = env.from_string('{{ o|urlescape }}')375 assert tmpl.render(o=u"Hello, world\u203d") == "Hello%2C%20world%E2%80%BD"376 assert tmpl.render(o=(("f", 1),)) == "f=1"377 assert tmpl.render(o=(('f', 1), ("z", 2))) == "f=1&z=2"378 assert tmpl.render(o=((u"\u203d", 1),)) == "%E2%80%BD=1"379 assert tmpl.render(o={u"\u203d": 1}) == "%E2%80%BD=1"380381def suite():382 suite = unittest.TestSuite()383 suite.addTest(unittest.makeSuite(FilterTestCase))
1 unmodified line
modified:jinja2/filters.py+17 added-6 removed
69 unmodified lines
70 value = value.__html__()71 return escape(unicode(value))7273def do_urlescape(value):74 """Escape for use in URLs."""75 return urllib.quote(value.encode('utf8'))74 """Escape strings for use in URLs (uses UTF-8 encoding)."""75 def utf8(o):76 return unicode(o).encode('utf8')77 78 if isinstance(value, basestring):79 return urllib.quote(utf8(value))80 81 if hasattr(value, 'items'):82 # convert dictionaries to list of 2-tuples83 value = value.items()84 85 if hasattr(value, 'next'):86 # convert generators to list87 value = list(value)88 89 return urllib.urlencode([(utf8(k), utf8(v)) for (k, v) in value])9091@evalcontextfilter92def do_replace(eval_ctx, s, old, new, count=None):93 """Return a copy of the value with all occurrences of a substring
721 unmodified lines
815 'round': do_round,816 'groupby': do_groupby,817 'safe': do_mark_safe,818 'xmlattr': do_xmlattr,805 'urlescape': do_urlescape,806 'urle': do_urlescape,807 'urlencode': do_urlescape,808 'urlquote': do_urlescape819 'urlescape': do_urlescape820}