django.forms.fields.URLField rejects valid URLs with no abs_path component
|Reported by:||wam||Owned by:||Honza_Kral|
|Cc:||Triage Stage:||Fixed on a branch|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
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:
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.
Change History (3)
Changed 6 years ago by wam
comment:1 Changed 6 years ago by Honza_Kral
- Needs documentation unset
- Needs tests unset
- Owner changed from nobody to Honza_Kral
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Fixed on a branch