From 0a9b7519582bc358be10bb374bfbdfe237e09578 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Mon, 4 Feb 2008 05:45:17 +0000 Subject: queryset-refactor: Merged changes from trunk up to [7085]. git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7086 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/utils/html.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'django/utils/html.py') diff --git a/django/utils/html.py b/django/utils/html.py index 33e2ee3856..17ff78a2b5 100644 --- a/django/utils/html.py +++ b/django/utils/html.py @@ -102,18 +102,23 @@ def urlize(text, trim_url_limit=None, nofollow=False, autoescape=False): if middle.startswith('www.') or ('@' not in middle and not middle.startswith('http://') and \ len(middle) > 0 and middle[0] in string.ascii_letters + string.digits and \ (middle.endswith('.org') or middle.endswith('.net') or middle.endswith('.com'))): - middle = '%s' % ( - urlquote(middle, safe='/&=:;#?+'), nofollow_attr, - trim_url(middle)) + middle = 'http://%s' % middle if middle.startswith('http://') or middle.startswith('https://'): - middle = '%s' % ( - urlquote(middle, safe='/&=:;#?+'), nofollow_attr, - trim_url(middle)) - if '@' in middle and not middle.startswith('www.') and \ - not ':' in middle and simple_email_re.match(middle): + url = urlquote(middle, safe='/&=:;#?+*') + if autoescape and not safe_input: + url = escape(url) + trimmed_url = trim_url(middle) + middle = '%s' % (url, nofollow_attr, + trimmed_url) + elif '@' in middle and not middle.startswith('www.') and \ + not ':' in middle and simple_email_re.match(middle): + if autoescape: + middle = conditional_escape(middle) middle = '%s' % (middle, middle) if lead + middle + trail != word: - words[i] = lead + middle + trail + if autoescape and not safe_input: + lead, trail = escape(lead), escape(trail) + words[i] = mark_safe('%s%s%s' % (lead, middle, trail)) elif autoescape and not safe_input: words[i] = escape(word) elif safe_input: -- cgit v1.3