words = _word_split_re.split(text_type(escape(text)))
nofollow_attr = nofollow and ' rel="nofollow"' or ''
if target is not None and isinstance(target, string_types):
- target_attr = ' target="%s"' % target
+ target_attr = ' target="%s"' % escape(target)
else:
target_attr = ''
for i, word in enumerate(words):
import pickle
-from jinja2.utils import LRUCache, escape, object_type_repr
+from jinja2.utils import LRUCache, escape, object_type_repr, urlize
@pytest.mark.utils
escape(u"<foo>")
counts.add(len(gc.get_objects()))
assert len(counts) == 1, 'ouch, c extension seems to leak objects'
+
+
+@pytest.mark.utils
+@pytest.mark.escapeUrlizeTarget
+class TestEscapeUrlizeTarget():
+ def test_escape_urlize_target(self):
+ url = "http://example.org"
+ target = "<script>"
+ assert urlize(url, target=target) == ('<a href="http://example.org"'
+ ' target="<script>">'
+ 'http://example.org</a>')