Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is_url returns false on uppercase URL scheme #64

Closed
hybby opened this issue Oct 6, 2020 · 2 comments · Fixed by #67
Closed

is_url returns false on uppercase URL scheme #64

hybby opened this issue Oct 6, 2020 · 2 comments · Fixed by #67
Assignees
Labels
bug Something isn't working
Milestone

Comments

@hybby
Copy link

hybby commented Oct 6, 2020

What?

I've found that checking a URL with an uppercase scheme name with the is_url checker results in a "False" result.

Desired Behaviour

RFC-3986 specifies that the scheme portion of a URL should be case-insensitive:

Scheme names consist of a sequence of characters beginning with a
letter and followed by any combination of letters, digits, plus
("+"), period ("."), or hyphen ("-"). Although schemes are case-
insensitive, the canonical form is lowercase and documents that
specify schemes must do so with lowercase letters. An implementation
should accept uppercase letters as equivalent to lowercase in scheme
names (e.g., allow "HTTP" as well as "http") for the sake of
robustness but should only produce lowercase scheme names for
consistency.

I believe that the checker should return "True" if an uppercase scheme is provided, even if the validator wants to coerce it to lowercase later. I'd be interested to hear your thoughts 😄

Demonstration

$ pip3 freeze | grep validator-collection
validator-collection==1.4.2

$ python3
Python 3.7.7 (default, Jun 29 2020, 14:21:56)
[Clang 11.0.3 (clang-1103.0.32.59)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from validator_collection import checkers
>>> url = "https://www.google.com"
>>> checkers.is_url(url)
True
>>> url = "HTTPS://www.google.com"
>>> checkers.is_url(url)
False

The desired behaviour would be:

>>> url = "HTTPS://www.google.com"
>>> checkers.is_url(url)
True
@insightindustry insightindustry self-assigned this Oct 6, 2020
@insightindustry insightindustry added the bug Something isn't working label Oct 6, 2020
@insightindustry insightindustry added this to the v.1.4.3 milestone Oct 6, 2020
@insightindustry
Copy link
Owner

Yep, this definitely looks like a bug. I’ll fix it in the next release. Good catch, and thanks!

@hybby
Copy link
Author

hybby commented Oct 12, 2020

Thanks for the quick bugfix! Appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants