Ticket #6279: urlize.diff
File urlize.diff, 2.3 KB (added by , 17 years ago) |
---|
-
django/utils/html.py
112 112 if '@' in middle and not middle.startswith('www.') and \ 113 113 not ':' in middle and simple_email_re.match(middle): 114 114 middle = '<a href="mailto:%s">%s</a>' % (middle, middle) 115 if lead: 116 lead = escape(lead) 117 if trail: 118 trail = escape(trail) 115 119 if lead + middle + trail != word: 116 120 words[i] = lead + middle + trail 117 121 elif autoescape and not safe_input: -
tests/regressiontests/templates/filters.py
108 108 'filter-urlize05': ('{% autoescape off %}{{ a|urlize }}{% endautoescape %}', {"a": "<script>alert('foo')</script>"}, "<script>alert('foo')</script>"), 109 109 'filter-urlize06': ('{{ a|urlize }}', {"a": "<script>alert('foo')</script>"}, '<script>alert('foo')</script>'), 110 110 111 # Test urlize with mailto: links 112 'filter-urlize07': ('{{ a|urlize }}', {"a": "Email me at me@example.com"}, 'Email me at <a href="mailto:me@example.com">me@example.com</a>'), 113 'filter-urlize08': ('{{ a|urlize }}', {"a": "Email me at <me@example.com>"}, 'Email me at <<a href="mailto:me@example.com">me@example.com</a>>'), 114 111 115 'filter-urlizetrunc01': ('{% autoescape off %}{{ a|urlizetrunc:"8" }} {{ b|urlizetrunc:"8" }}{% endautoescape %}', {"a": '"Unsafe" http://example.com/x=&y=', "b": mark_safe('"Safe" http://example.com?x=&y=')}, u'"Unsafe" <a href="http://example.com/x=&y=" rel="nofollow">http:...</a> "Safe" <a href="http://example.com?x=&y=" rel="nofollow">http:...</a>'), 112 116 'filter-urlizetrunc02': ('{{ a|urlizetrunc:"8" }} {{ b|urlizetrunc:"8" }}', {"a": '"Unsafe" http://example.com/x=&y=', "b": mark_safe('"Safe" http://example.com?x=&y=')}, u'"Unsafe" <a href="http://example.com/x=&y=" rel="nofollow">http:...</a> "Safe" <a href="http://example.com?x=&y=" rel="nofollow">http:...</a>'), 113 117