mitsuhiko /
jinja2-main
(http://jinja.pocoo.org/)
Mirror of jinja2-main.
Clone URL : http://bitbucket.org/mitsuhiko/jinja2-main/ (size: 1.5 MB)
| commit 594: | b24e3ab4e500 |
| parent 593: | 33908b3b84c6 |
| branch: | trunk |
Fixed an escaping bug in urlize
Changed (Δ285 bytes):
raw changeset »
CHANGES (2 lines added, 0 lines removed)
jinja2/filters.py (1 lines added, 1 lines removed)
jinja2/utils.py (1 lines added, 1 lines removed)
tests/test_old_bugs.py (5 lines added, 0 lines removed)
| … | … | @@ -44,6 +44,8 @@ Version 2.1 |
44 |
44 |
- added a `compile_expression` method to the environment that allows compiling |
45 |
45 |
of Jinja expressions into callable Python objects. |
46 |
46 |
|
47 |
- fixed an escaping bug in urlize |
|
48 |
||
47 |
49 |
Version 2.0 |
48 |
50 |
----------- |
49 |
51 |
(codename jinjavitus, released on July 17th 2008) |
Up to file-list jinja2/filters.py:
| … | … | @@ -322,7 +322,7 @@ def do_urlize(environment, value, trim_u |
322 |
322 |
{{ mytext|urlize(40, true) }} |
323 |
323 |
links are shortened to 40 chars and defined with rel="nofollow" |
324 |
324 |
""" |
325 |
rv = urlize( |
|
325 |
rv = urlize(value, trim_url_limit, nofollow) |
|
326 |
326 |
if environment.autoescape: |
327 |
327 |
rv = Markup(rv) |
328 |
328 |
return rv |
Up to file-list jinja2/utils.py:
| … | … | @@ -218,7 +218,7 @@ def urlize(text, trim_url_limit=None, no |
218 |
218 |
trim_url = lambda x, limit=trim_url_limit: limit is not None \ |
219 |
219 |
and (x[:limit] + (len(x) >=limit and '...' |
220 |
220 |
or '')) or x |
221 |
words = _word_split_re.split( |
|
221 |
words = _word_split_re.split(unicode(escape(text))) |
|
222 |
222 |
nofollow_attr = nofollow and ' rel="nofollow"' or '' |
223 |
223 |
for i, word in enumerate(words): |
224 |
224 |
match = _punctuation_re.match(word) |
Up to file-list tests/test_old_bugs.py:
| … | … | @@ -28,3 +28,8 @@ def test_extends_output_bugs(): |
28 |
28 |
'{% for item in [1, 2, 3] %}({{ item }}){% endfor %}') |
29 |
29 |
assert t.render(expr=False) == '[[title]](1)(2)(3)' |
30 |
30 |
assert t.render(expr=True) == '((title))' |
31 |
||
32 |
||
33 |
def test_urlize_filter_escaping(env): |
|
34 |
tmpl = env.from_string('{{ "http://www.example.org/<foo"|urlize }}') |
|
35 |
assert tmpl.render() == '<a href="http://www.example.org/<foo">http://www.example.org/<foo</a>' |
