Update validators.py to allow for (more) correct URL Validation#19095
Update validators.py to allow for (more) correct URL Validation#19095ludwigkraatz wants to merge 1 commit intodjango:mainfrom
Conversation
fully allowing for URLs as per rfc3986#section-3.2.2 - with a regex solution for localhost (and whatever else is possible) instead of a hardcoded < "magicnumber"-80%-"solution" > what is not said in rfc3986, dealing with URI/URLs: - that a hostname requires multiple labels - thus - no "." is required to seperate them - actually, length limit of 63 is also not a given if we're not in a DNS context. but for simplistical reasons, i chose to keep it aligned to DNS-Labels, as provided via DomainNameValidator.hostname_re Why this is necessary & usefull: Single-label URLs might be used - in intranet situations - for URLs that represent services / schemes that do not comply to DNS naming conventions - for local testing (local DNS resolution that is not based on FQDN) - mDNS [RFC 6762] solutions, operating under .local TLD (which as of that RFC can be ommitted in a local context) - the validator is name URLValidator, not DNSURLValidator
|
EDIT: the following is to be ignored. its because the URLField is tested, which has lazy-scheme support btw: the test - test_urlfield_clean_invalid, seems to be a false negative outside of this merge request. because even with my changes, this should not be valid - and as such there seems to be a broader issue. I tested it: i was correct: there is a deeper issue see this pull request which tested for 'localhost' => URL field |
|
the issue is more complex than just to fix a regex. its the whole concept of URLValidator thats off - compared to what a valid URL really is. It has been called a design decision - which they never seem to have considered (and probably not going to) a '(semantic) bug' of sorts. as such - this issue does not seem to be tackled any time soon, if ever. |
fully allowing for URLs as per rfc3986#section-3.2.2 - with a regex solution for localhost (and whatever else is possible) instead of a hardcoded < "magicnumber"-80%-"solution" >
what is not said in rfc3986, dealing with URI/URLs:
Why this is necessary & usefull:
Single-label URLs might be used
Trac ticket number
ticket-36131
Branch description
Provide a concise overview of the issue or rationale behind the proposed changes.
Checklist
mainbranch.