- added a `compile_expression` method to the environment that allows compiling
of Jinja expressions into callable Python objects.
+- fixed an escaping bug in urlize
+
Version 2.0
-----------
(codename jinjavitus, released on July 17th 2008)
{{ mytext|urlize(40, true) }}
links are shortened to 40 chars and defined with rel="nofollow"
"""
- rv = urlize(soft_unicode(value), trim_url_limit, nofollow)
+ rv = urlize(value, trim_url_limit, nofollow)
if environment.autoescape:
rv = Markup(rv)
return rv
trim_url = lambda x, limit=trim_url_limit: limit is not None \
and (x[:limit] + (len(x) >=limit and '...'
or '')) or x
- words = _word_split_re.split(text)
+ words = _word_split_re.split(unicode(escape(text)))
nofollow_attr = nofollow and ' rel="nofollow"' or ''
for i, word in enumerate(words):
match = _punctuation_re.match(word)
'{% for item in [1, 2, 3] %}({{ item }}){% endfor %}')
assert t.render(expr=False) == '[[title]](1)(2)(3)'
assert t.render(expr=True) == '((title))'
+
+
+def test_urlize_filter_escaping(env):
+ tmpl = env.from_string('{{ "http://www.example.org/<foo"|urlize }}')
+ assert tmpl.render() == '<a href="http://www.example.org/<foo">http://www.example.org/<foo</a>'