Opened 17 years ago

Closed 17 years ago

#6019 closed (duplicate)

URLField does not allow URLs starting with ftp://

Reported by: Soeren Sonnenburg <bugreports@…> 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 Alex Gaynor, 17 years ago

Makes sense, are there any other protocols we would want to support.

comment:2 by Soeren Sonnenburg <bugreports@…>, 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 Soeren Sonnenburg <bugreports@…>, 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 Jacob, 17 years ago

Resolution: duplicate
Status: newclosed

I've created #6092 to track the bigger issue here.

comment:5 by anonymous, 17 years ago

Needs documentation: set
Resolution: duplicate
Status: closedreopened

please add rsync and nfs also

comment:6 by Ramiro Morales, 17 years ago

Resolution: duplicate
Status: reopenedclosed

Reverting anonymous reopen

Note: See TracTickets for help on using tickets.
Back to Top