Opened 11 years ago
Closed 11 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: | dev |
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 |
Description
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://example.com 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)
[1] https://en.wikipedia.org/wiki/URI_scheme#Official_IANA-registered_schemes
[2] https://tools.ietf.org/html/rfc3986
Change History (7)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
Component: | Uncategorized → Core (Other) |
---|---|
Has patch: | set |
Patch needs improvement: | set |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → New feature |
Version: | 1.5 → master |
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 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:5 by , 11 years ago
Patch needs improvement: | unset |
---|
I've provided an alternative patch, based on Sascha's patch: https://github.com/django/django/pull/2099
comment:6 by , 11 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:7 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
So https://github.com/django/django/pull/1717 addresses at least the ssh example, but I'd rather want to generalize URLValidator further.