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

URI with query string without equals sign is flagged as invalid #346

Closed
CBonnell opened this issue Mar 27, 2024 · 1 comment
Closed

URI with query string without equals sign is flagged as invalid #346

CBonnell opened this issue Mar 27, 2024 · 1 comment
Labels
expected Issue: Works as designed

Comments

@CBonnell
Copy link

It appears that with version 0.24, URIs with a query string that do not contain an equals sign are flagged as invalid. This appears to be more strict than what RFC 3986, section 3.4 prescribes.

For example, http://www.foo.example?bar is valid according to RFC 3986, but it is now flagged as invalid:

validators.url('http://www.foo.example?bar')

ValidationError(func=url, args={'reason': "bad query field: 'bar'", 'value': 'http://www.foo.example?bar'})
@CBonnell CBonnell changed the title URI with query string without equals sign is invalid URI with query string without equals sign is flagged as invalid Mar 27, 2024
@yozachar yozachar added the expected Issue: Works as designed label Mar 29, 2024
@yozachar
Copy link
Collaborator

yozachar commented Mar 29, 2024

try:
if (
query
# ref: https://github.com/python/cpython/issues/117109
and parse_qs(query, strict_parsing=strict_query, separator="&")
and parse_qs(query, strict_parsing=strict_query, separator=";")
):
optional_segments &= True
except TypeError:
# for Python < v3.9.2 (official v3.10)
if query and parse_qs(query, strict_parsing=strict_query):
optional_segments &= True

Please pass strict_query=False. Query validation is performed internally by Python's parse_qs function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
expected Issue: Works as designed
Projects
None yet
Development

No branches or pull requests

2 participants