[Django] #26418: models.URLField does not validate with an rtmp:// url

15 views
Skip to first unread message

Django

unread,
Mar 29, 2016, 12:32:44 PM3/29/16
to django-...@googlegroups.com
#26418: models.URLField does not validate with an rtmp:// url
------------------------------+--------------------
Reporter: gitfu | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
------------------------------+--------------------
models.URLField does not validate with an '''rtmp://''' url

checking the source, it is validated twice

class URLField(CharField):
'' default_validators = [validators.URLValidator()]
description = _("URL")

And

def formfield(self, **kwargs):
# As with CharField, this will cause URL validation to be
performed
# twice.
defaults = {
'form_class': forms.URLField,
}

in django.core.validators.UrlValidator we find at least one of the
culprits:

schemes = ['http', 'https', 'ftp', 'ftps']

RFC 3986 (I believe retained for RFC7320) defines scheme:

3.1. Scheme

Each URI begins with a scheme name that refers to a specification for
assigning identifiers within that scheme. As such, the URI syntax is
a federated and extensible naming system wherein each scheme's
specification may further restrict the syntax and semantics of
identifiers using that scheme.

Scheme names consist of a sequence of characters beginning with a
letter and followed by any combination of letters, digits, plus
("+"), period ("."), or hyphen ("-"). Although schemes are case-
insensitive, the canonical form is lowercase and documents that
specify schemes must do so with lowercase letters. An implementation
should accept uppercase letters as equivalent to lowercase in scheme
names (e.g., allow "HTTP" as well as "http") for the sake of
robustness but should only produce lowercase scheme names for
consistency.

scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )

--
Ticket URL: <https://code.djangoproject.com/ticket/26418>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 29, 2016, 12:49:59 PM3/29/16
to django-...@googlegroups.com
#26418: models.URLField does not validate with an rtmp:// url
------------------------------+--------------------------------------

Reporter: gitfu | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Old description:

New description:

3.1. Scheme

--

Comment:

It's not entirely clear what your proposal is, however, changing the
default list of accepted schemes would be backwards-incompatible as
described in #25593.

I believe solving #25594 would ease customizing the list of schemes and
address the concern of this ticket.

--
Ticket URL: <https://code.djangoproject.com/ticket/26418#comment:1>

Django

unread,
Mar 29, 2016, 1:28:47 PM3/29/16
to django-...@googlegroups.com
#26418: models.URLField does not validate with an rtmp:// url
------------------------------+--------------------------------------

Reporter: gitfu | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
------------------------------+--------------------------------------

Comment (by gitfu):

Having a list of schemes will always be problematic,

How about a models.URIField that matches the pattern specified in the rfc
for the scheme?

That maintains the backwards compatibility for models.URLField, and avoids
a messy work around.

--
Ticket URL: <https://code.djangoproject.com/ticket/26418#comment:2>

Django

unread,
Mar 29, 2016, 4:36:54 PM3/29/16
to django-...@googlegroups.com
#26418: models.URLField does not validate with an rtmp:// url
------------------------------+--------------------------------------

Reporter: gitfu | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
------------------------------+--------------------------------------

Comment (by claudep):

It might make sense to provide some special value for `scheme`, like
`__all__`, to allow for all possible schemes (in the same spirit as the
`ModelForm.fields/.exclude` variables).

--
Ticket URL: <https://code.djangoproject.com/ticket/26418#comment:3>

Django

unread,
Mar 30, 2016, 9:08:12 AM3/30/16
to django-...@googlegroups.com
#26418: models.URLField does not validate with an rtmp:// url
------------------------------+--------------------------------------
Reporter: gitfu | Owner: nobody
Type: Bug | Status: closed

Component: Core (Other) | Version: 1.9
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by timgraham):

* status: new => closed
* resolution: => wontfix


Comment:

You could propose `URIField` on the DevelopersMailingList. I'm not aware
of any previous proposals about it. We can open a new ticket if the idea
is accepted.

I created #26424 for Claude's idea of allowing `URLValidator` to skip the
schemes validation.

--
Ticket URL: <https://code.djangoproject.com/ticket/26418#comment:4>

Reply all
Reply to author
Forward
0 new messages