Opened 5 years ago

Closed 5 years ago

#21242 closed New feature (fixed)

Allow more IANA schemes in URLValidator

Reported by: Sascha peilicke Owned by: Sascha peilicke
Component: Core (Other) Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Currently, URLValidator only allows the following schemes: http(s) and ftp(s). Since the formal definition of URL (being a subset of URI) includes many more valid schemes [1], URLValidator should be expanded to allow those. Of course Django users could create their own validator but this seems to be a rather common task it's probably better to have that in core Django.

An alternative solution would be to provide an URIValidator which allows more schemes than what we currently have in URLValidator. However, since sth. like ssh:// is not only a valid URI but also a valid URL [2] it doesn't seem to make sense to differentiate URI and URL.

Related to that, #15229 already added support for ftp(s)


Change History (7)

comment:1 Changed 5 years ago by Sascha peilicke

So addresses at least the ssh example, but I'd rather want to generalize URLValidator further.

comment:2 Changed 5 years ago by Claude Paroz

Component: UncategorizedCore (Other)
Has patch: set
Patch needs improvement: set
Triage Stage: UnreviewedAccepted
Type: UncategorizedNew feature
Version: 1.5master

Yes, this might be interesting, but only if we generalize accepted schemes. We should probably add a new scheme init parameter allowing to specify a scheme list (defaulting to ['http', 'https', 'ftp', 'ftps']), and then check for valid schemes in __call__.

comment:3 Changed 5 years ago by Sascha peilicke

Owner: changed from nobody to Sascha peilicke
Status: newassigned

comment:5 Changed 5 years ago by Claude Paroz

Patch needs improvement: unset

I've provided an alternative patch, based on Sascha's patch:

comment:6 Changed 5 years ago by Tim Graham

Triage Stage: AcceptedReady for checkin

comment:7 Changed 5 years ago by Claude Paroz <claude@…>

Resolution: fixed
Status: assignedclosed

In 6d66ba59488bbd0d4f0c2f32b2921f1512301143:

Fixed #21242 -- Allowed more IANA schemes in URLValidator

Thanks Sascha Peilicke for the report and initial patch, and
Tim Graham for the review.

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