Code

Ticket #11551: forms.fields.diff

File forms.fields.diff, 806 bytes (added by adamnelson, 5 years ago)

Allows file:/// url type

Line 
1Index: /Users/adam/Development/django-trunk/django/forms/fields.py
2===================================================================
3--- /Users/adam/Development/django-trunk/django/forms/fields.py (revision 11326)
4+++ /Users/adam/Development/django-trunk/django/forms/fields.py (working copy)
5@@ -532,11 +532,11 @@
6         return f
7 
8 url_re = re.compile(
9-    r'^https?://' # http:// or https://
10+    r'^https?://|file:///?' # http:// or https:// or file:// or file:///
11     r'(?:(?:[A-Z0-9]+(?:-*[A-Z0-9]+)*\.)+[A-Z]{2,6}|' #domain...
12-    r'localhost|' #localhost...
13+    r'localhost|' # ... or localhost
14     r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
15-    r'(?::\d+)?' # optional port
16+    r'(?::\d{1,5})?' # optional port
17     r'(?:/?|/\S+)$', re.IGNORECASE)
18 
19 class URLField(RegexField):