Opened 17 years ago
Closed 17 years ago
#6019 closed (duplicate)
URLField does not allow URLs starting with ftp://
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Uncategorized | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | yes |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
basically line 409 in newforms/fields.py is too restrictive
instead of
url_re = re.compile( r'^https?://' # http:// or https:// r'(?:(?:[A-Z0-9-]+\.)+[A-Z]{2,6}|' #domain... r'localhost|' #localhost... r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip r'(?::\d+)?' # optional port r'(?:/?|/\S+)$', re.IGNORECASE)
it should rather be
url_re = re.compile( r'^(ftp|https?)://' # http:// or https:// r'(?:(?:[A-Z0-9-]+\.)+[A-Z]{2,6}|' #domain... r'localhost|' #localhost... r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip r'(?::\d+)?' # optional port r'(?:/?|/\S+)$', re.IGNORECASE)
to allow normal ftp://foo.bar urls - this works with validation too...
Change History (6)
comment:1 by , 17 years ago
comment:2 by , 17 years ago
I could not think of anything else, e.g. mailto:// is handled in a separate field and cannot be checked the same way, file:// does not really make sense, gopher:// is not exactly popular...
comment:3 by , 17 years ago
on the other hand, one could be future proof(tm) and add a prefix argument that defaults to url_prefix='(ftp|https?)' which is then integrated in the re ...
comment:4 by , 17 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
I've created #6092 to track the bigger issue here.
comment:5 by , 17 years ago
Needs documentation: | set |
---|---|
Resolution: | duplicate |
Status: | closed → reopened |
please add rsync and nfs also
comment:6 by , 17 years ago
Resolution: | → duplicate |
---|---|
Status: | reopened → closed |
Reverting anonymous reopen
Makes sense, are there any other protocols we would want to support.