Code

Opened 6 years ago

Closed 6 years ago

#6019 closed (duplicate)

URLField does not allow URLs starting with ftp://

Reported by: Soeren Sonnenburg <bugreports@…> Owned by: nobody
Component: Uncategorized Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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...

Attachments (0)

Change History (6)

comment:1 Changed 6 years ago by Alex

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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

comment:2 Changed 6 years ago by Soeren Sonnenburg <bugreports@…>

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 Changed 6 years ago by Soeren Sonnenburg <bugreports@…>

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 Changed 6 years ago by jacob

  • Resolution set to duplicate
  • Status changed from new to closed

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

comment:5 Changed 6 years ago by anonymous

  • Needs documentation set
  • Resolution duplicate deleted
  • Status changed from closed to reopened

please add rsync and nfs also

comment:6 Changed 6 years ago by ramiro

  • Resolution set to duplicate
  • Status changed from reopened to closed

Reverting anonymous reopen

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.