#32930: URLValidator does not accept urls with port number < 10
----------------------------------------+------------------------------
Reporter: Wu Haotian | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: 3.2
Severity: Normal | Keywords: URLValidator
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------+------------------------------
{{{
>>> from django.core.validators import URLValidator
>>> URLValidator()("https://code.djangoproject.com:1")
Traceback (most recent call last):
.....
raise ValidationError(self.message, code=self.code, params={'value':
value})
django.core.exceptions.ValidationError: <unprintable ValidationError
object>
}}}
The commit[1] for fixing Ticket #20003 added port length checks in
URLValidator, but I didn't see why in the ticket comments or commit
description.
Given that:
The URL Standard from WhatWG[2] defines URL Port as:
A URL’s port is either null or a 16-bit unsigned integer that
identifies a networking port. It is initially null.
RFC 3986[3] defines "port" as "*DIGIT", and does not requires the length
of port.
I believe URLs with port number < 10 should be valid URLs.
[1]
https://github.com/django/django/commit/2e65d56156b622e2393dee1af66e9c799a51924f
#diff-d9609d8dc8482b30eac30df16213cba134562949fd62c97573927b89e880f85bR85
[2] https://url.spec.whatwg.org/#concept-url-port
[3] https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.3
--
Ticket URL: <https://code.djangoproject.com/ticket/32930>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/049.2115e3e88c5b98fb8f0a6a4d732c5c4d%40djangoproject.com.