mirror of
https://github.com/django/django.git
synced 2025-10-26 07:06:08 +00:00
Fixed #12183 -- Made the urlize filter insert the nofollow attribute properly when an http: URL occurs after a mailto: URL. Thanks eronen for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17356 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -141,7 +141,6 @@ def urlize(text, trim_url_limit=None, nofollow=False, autoescape=False):
|
||||
trim_url = lambda x, limit=trim_url_limit: limit is not None and (len(x) > limit and ('%s...' % x[:max(0, limit - 3)])) or x
|
||||
safe_input = isinstance(text, SafeData)
|
||||
words = word_split_re.split(force_unicode(text))
|
||||
nofollow_attr = nofollow and ' rel="nofollow"' or ''
|
||||
for i, word in enumerate(words):
|
||||
match = None
|
||||
if '.' in word or '@' in word or ':' in word:
|
||||
@@ -150,6 +149,7 @@ def urlize(text, trim_url_limit=None, nofollow=False, autoescape=False):
|
||||
lead, middle, trail = match.groups()
|
||||
# Make URL we want to point to.
|
||||
url = None
|
||||
nofollow_attr = ' rel="nofollow"' if nofollow else ''
|
||||
if middle.startswith('http://') or middle.startswith('https://'):
|
||||
url = smart_urlquote(middle)
|
||||
elif middle.startswith('www.') or ('@' not in middle and \
|
||||
|
||||
Reference in New Issue
Block a user