#32874: URLValidator is not validating schema relative URLs
---------------------------------+--------------------------------------
     Reporter:  Maciej Strömich  |                    Owner:  nobody
         Type:  Bug              |                   Status:  new
    Component:  Uncategorized    |                  Version:  3.2
     Severity:  Normal           |               Resolution:
     Keywords:                   |             Triage Stage:  Unreviewed
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+--------------------------------------

Old description:

> Based on rfc1808#section-2.4.3 a valid schema relative URL is the one
> starting with `//`
>
> URLValidator is not validating such urls.
>
> ```
> >>> from django.core.validators import URLValidator
> >>> value = '//example.com'
> >>> URLValidator().__call__(value)
> Traceback (most recent call last):
>   File "<console>", line 1, in <module>
>   File "/opt/venv/lib/python3.8/site-packages/django/core/validators.py",
> line 110, in __call__
>     raise ValidationError(self.message, code=self.code, params={'value':
> value})
> django.core.exceptions.ValidationError: ['Enter a valid URL.']
> ```

New description:

 Based on rfc1808#section-2.4.3 a valid schema relative URL is the one
 starting with `//`

 URLValidator is not validating such urls.

 {{{
 >>> from django.core.validators import URLValidator
 >>> value = '//example.com'
 >>> URLValidator().__call__(value)
 Traceback (most recent call last):
   File "<console>", line 1, in <module>
   File "/opt/venv/lib/python3.8/site-packages/django/core/validators.py",
 line 110, in __call__
     raise ValidationError(self.message, code=self.code, params={'value':
 value})
 django.core.exceptions.ValidationError: ['Enter a valid URL.']
 }}}

--

Comment (by Maciej Strömich):

 formatting

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32874#comment:1>
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/072.f362b5b82bb63f1ddecbb508babffcbb%40djangoproject.com.

Reply via email to