Opened 15 years ago
Closed 15 years ago
#11826 closed (fixed)
django.forms.fields.URLField rejects valid URLs with no abs_path component
Reported by: | wam | Owned by: | Honza Král |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Fixed on a branch | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
As annoying as it is, RFC 2616 section 3.2.2 (http://www.rfc2616.com/#3.2.2) allows the abs_path component (the pathname following the optional port number) to be optional in an HTTP URL (it implicitly becomes '/', and is required to treated as '/' for sake of comparisons as well as for request processing). However, the definition of django.forms.fields.url_re requires the character following the optional port number to be a /. The regex also allows the URL to just end after the port with no abs_path, but it currently rejects URLs like:
http://example.com?some_param=some_value
Additionally, the clean() method tacks on a trailing slash to URLs that don't have a pathname.
Attached to this ticket will be a patch to django/forms/fields.py which properly handles URLs like the one listed above by normalizing it to the version that is suitable for URI comparison (see http://www.rfc2616.com/#3.2.3). The patch will also provide an additional testcase to tests/regressiontests/forms/fields.py which includes the URL above along with it's expected normalization.
Attachments (1)
Change History (3)
by , 15 years ago
Attachment: | rfc2616-ticket11826.patch added |
---|
comment:1 by , 15 years ago
Owner: | changed from | to
---|---|
Triage Stage: | Unreviewed → Fixed on a branch |
Fixed on model-validation branch in [11525]
comment:2 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
With model-validation merged, this is fixed in [12098]
Patch to url_re to allow URLs with no abs_name component, plus testcase