Opened 6 days ago
Closed 5 days ago
#36007 closed Cleanup/optimization (fixed)
Dead code in URLValidator
Reported by: | Mike Edmunds | Owned by: | Mike Edmunds |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
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
There's some dead code in django.core.validators.URLValidator which could be removed:
- The entire Trivial case failed. Try for possible IDN domain section is no longer useful. This code attempts to re-validate a failed URL after encoding an international domain name using IDNA 2003 ("punycode"). But the URLValidator regular expressions have allowed all IDNs since Commit 2e65d56 (for #20003, in 2015), so the super call will never fail with a validation error that switching to IDNA 2003 would let pass.
- The `ul` unicode letters property is no longer used. The regular expressions that had used it were moved into DomainNameValidator in Commit 4971a9a (for #18119, in Django 5.1).
For the first case, one way to verify the code is no longer in use is to run URLValidator on https://މިހާރު.com
, which is a domain allowed by IDNA 2008 but prohibited by IDNA 2003. If the punycode() branch were coming into play, that URL would be rejected:
from django.core.validators import URLValidator URLValidator()("https://މިހާރު.com") # (No error) from django.utils.encoding import punycode punycode("މިހާރު.com") # UnicodeError: Violation of BIDI requirement 3 # encoding with 'idna' codec failed
Change History (5)
comment:1 by , 6 days ago
Has patch: | set |
---|
comment:2 by , 5 days ago
Component: | Uncategorized → Core (Other) |
---|---|
Triage Stage: | Unreviewed → Ready for checkin |
Version: | 5.1 → dev |
comment:3 by , 5 days ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:4 by , 5 days ago
Note:
See TracTickets
for help on using tickets.
In 9a891c38: