#32930: URLValidator should accept urls with port number < 10
------------------------------+--------------------------------------
     Reporter:  Wu Haotian    |                    Owner:  Wu Haotian
         Type:  Bug           |                   Status:  assigned
    Component:  Core (Other)  |                  Version:  3.2
     Severity:  Normal        |               Resolution:
     Keywords:  URLValidator  |             Triage Stage:  Accepted
    Has patch:  0             |      Needs documentation:  0
  Needs tests:  0             |  Patch needs improvement:  0
Easy pickings:  0             |                    UI/UX:  0
------------------------------+--------------------------------------

Comment (by Wu Haotian):

 It's hard to validating port using regex only.. Given that `0443` and
 `000080` are both valid ports in URL.

 {{{
 >>> import requests
 >>> requests.get("https://code.djangoproject.com:0443";)
 <Response [200]>
 >>> requests.get("https://code.djangoproject.com:00000443";)
 <Response [200]>
 }}}


 {{{
 > curl -I http://example.com:0000000000080
 HTTP/1.1 200 OK
 Content-Encoding: gzip
 Accept-Ranges: bytes
 Age: 591287
 Cache-Control: max-age=604800
 Content-Type: text/html; charset=UTF-8
 Date: Thu, 15 Jul 2021 09:51:52 GMT
 Etag: "3147526947"
 Expires: Thu, 22 Jul 2021 09:51:52 GMT
 Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT
 Server: ECS (sab/5693)
 X-Cache: HIT
 Content-Length: 648
 }}}

 I'd prefer to use `\d+` -- it's not perfect, but should produce fewer
 false negatives.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32930#comment:5>
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/064.c84e6720a62c474e0fcb6a3cf3470931%40djangoproject.com.

Reply via email to