-
Notifications
You must be signed in to change notification settings - Fork 32
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
Incorrect result returned by is_valid_uri() #30
Comments
Really this method should be # A no-scheme path with zero extra segments
>>> rfc3986.uri_reference('1')
URIReference(scheme=None, authority=None, path='1', query=None, fragment=None)
# A relative-ref with an empty path and no scheme.
>>> rfc3986.uri_reference('//')
URIReference(scheme=None, authority=None, path=None, query=None, fragment=None)
# A relative-ref with a non-empty path and a fragment.
>>> rfc3986.uri_reference('http#:/')
URIReference(scheme=None, authority=None, path='http', query=None, fragment=':/') |
Right. There's a far better and more comprehensive way of doing validations |
rfc3986.is_valid_uri("Hi Super Nintendo Chalmers") # -> True
rfc3986.is_valid_uri("My cat's breath smells like cat food.") # -> True
rfc3986.is_valid_uri("I'm learnding!") # -> True Something is deeply wrong here. |
@bugeats All of those examples pass the validation check because Using the def is_valid_uri_with_scheme_and_host(uri):
try:
uri = rfc3986.URIReference.from_string(uri)
rfc3986.validators.Validator().require_presence_of("scheme", "host").check_validity_of("scheme", "host").validate(uri)
return True
except MissingComponentError, InvalidComponentsError:
return False Will return |
Yes I eventually figured that out, thanks for the detailed response. I mostly wanted to point out the absurdity of the code as it reads. I humbly suggest that you reconsider the name of that method. |
Or just remove it, it's been deprecated for a few releases. |
I want to use this library to detect |
Anyone? |
Almost a year late to the party here. If you don't mind using something home-grown, you could try using it. |
According to RFC 3986, there are some ABNF rules:
URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / ".")
And I tried:
I think these results are not correct.
The text was updated successfully, but these errors were encountered: