﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
7355	Urlize function in django.utils.html does not properly work on https:// links	clint	nobody	"Just tested this out on the version of utils/html.py in [7569]

urlize() incorrectly adds a http:// to the beginning of a https link

To replicate:
{{{
>>> from django.utils.html import urlize
>>> words = ""Hi there https://www.google.com""
>>> urlize(words)
u'Hi there <a href=""http://https://www.google.com"">http://https://www.google.com</a>'
}}}

I did a search in trac for ""urlize https"" and came up with no hits.  As far as I can tell this bug has been around for a while, not sure why no one would've caught this.

{{{
Patch:
===================================================================
--- html.py	(revision 7569)
+++ html.py	(working copy)
@@ -99,7 +99,7 @@
             lead, middle, trail = match.groups()
             if safe_input:
                 middle = mark_safe(middle)
-            if middle.startswith('www.') or ('@' not in middle and not middle.startswith('http://') and \
+            if middle.startswith('www.') or ('@' not in middle and not (middle.startswith('http://') or middle.startswith('https://')) 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 = 'http://%s' % middle
}}}


And a test to check for this
{{{
Index: tests.py
===================================================================
--- tests.py	(revision 7569)
+++ tests.py	(working copy)
@@ -166,6 +166,11 @@
 >>> urlizetrunc(uri, 2)
 u'<a href=""http://31characteruri.com/test/"" rel=""nofollow"">...</a>'
 
+# Check normal urlize
+>>> url = 'https://google.com'
+>>> urlize(url)
+u'<a href=""https://google.com"" rel=""nofollow"">https://google.com</a>'
+
 >>> wordcount('')
 0
}}}
"		closed	Core (Other)	dev		fixed			Ready for checkin	1	0	0	0		
