Opened 3 years ago

Last modified 3 years ago

#32874 closed New feature

URLValidator is not validating schema relative URLs — at Version 1

Reported by: Maciej Strömich Owned by: nobody
Component: Core (Other) Version: 3.2
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Maciej Strömich)

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.']

Change History (1)

comment:1 by Maciej Strömich, 3 years ago

Description: modified (diff)

formatting

Note: See TracTickets for help on using tickets.
Back to Top