Opened 8 years ago

Last modified 8 years ago

#25595 new Bug

Invalid regexp in URLValidator can't handle file:// schemes

Reported by: Marcin Nowak Owned by: nobody
Component: Core (Other) Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Regexp does not allow to use file scheme in URLValidator.

Steps to reproduce

from django.core.validators import URLValidator

Expected result

No exception should be raised.

Current result

ValidationError: [u'Enter a valid URL.']

Change History (5)

comment:1 by Tim Graham, 8 years ago

Component: UncategorizedCore (Other)
Triage Stage: UnreviewedAccepted

Can this be fixed without special casing the file scheme in the validation?

comment:2 by Claude Paroz, 8 years ago

It's URLValidator not URIValidator, I think you might need your own custom validator for this. The current regex is already bloated, I'm not sure we should continue to complexify it...

comment:3 by Tim Graham, 8 years ago

I had a similar skepticism. If we don't make a change, then let's clarify the documentation to prevent further tickets about this.

comment:4 by Johannes Maron, 8 years ago

I thinks this is both a documentation and code problem. The URLValidator should raise a value error, if a unsupported schema is set. In the documentation it should be explained which schemas are supported. Currently one gets the impression that all are.

Last edited 8 years ago by Johannes Maron (previous) (diff)

comment:5 by Johannes Maron, 8 years ago

Interestingly enough, if you include the optional host parameter in RFC1738 it works: file://localhost/tmp/file/name

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