Opened 5 years ago

Closed 5 years ago

#31548 closed Bug (fixed)

URLValidator crashes on non-strings.

Reported by: Vasiliy Bondarenko Owned by: Yash Saini
Component: Core (Other) Version: 3.0
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

URLValidator is expected to raise ValidationError for empty string, instead it fails on .split statement with general error:
AttributeError: 'NoneType' object has no attribute 'split'
or
AttributeError: 'int' object has no attribute 'split'
etc.

in django/core/validators.py


    def __call__(self, value):
        # Check first if the scheme is valid
        scheme = value.split('://')[0].lower()
        if scheme not in self.schemes:
            raise ValidationError(self.message, code=self.code)

Change History (5)

comment:1 by Yash Saini, 5 years ago

Component: UncategorizedCore (Other)
Owner: changed from nobody to Yash Saini
Status: newassigned
Triage Stage: UnreviewedAccepted

comment:2 by Mariusz Felisiak, 5 years ago

Summary: URLValidator is expected to raise ValidationError for empty string or not string at all.URLValidator crashes on None, empty strings, and non-strings.

comment:4 by Mariusz Felisiak, 5 years ago

Summary: URLValidator crashes on None, empty strings, and non-strings.URLValidator crashes on non-strings.
Triage Stage: AcceptedReady for checkin

comment:5 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In ccb1cfb:

Fixed #31548 -- Fixed URLValidator crash on non-strings.

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