Skip to content

URL validator fails is dollar sign '$' is used in the query parameters #306

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

Closed
damianr13 opened this issue Oct 9, 2023 · 1 comment · Fixed by #305
Closed

URL validator fails is dollar sign '$' is used in the query parameters #306

damianr13 opened this issue Oct 9, 2023 · 1 comment · Fixed by #305
Labels
bug Issue: Works not as designed

Comments

@damianr13
Copy link

Bug description

Example url:
https://services.odata.org/OData/OData.svc/Products?$skip=2&$top=2&$orderby=Rating

The URL above is taken from the Open Data Protocol documentation page.

If we try to validate it:

validators.url("https://services.odata.org/OData/OData.svc/Products?$skip=2&$top=2&$orderby=Rating")

We get the following output:

ValidationError(func=url, args={'value': 'https://services.odata.org/OData/OData.svc/Products?$skip=2&$top=2&$orderby=Rating'})

If we remove the dollar signs:

https://services.odata.org/OData/OData.svc/Products?skip=2&top=2&orderby=Rating

The output simply shows:

True

Expected behaviour

Allow dolllar sign in URL query.

validators.url("https://services.odata.org/OData/OData.svc/Products?$skip=2&$top=2&$orderby=Rating")

Should return

True
@yozachar
Copy link
Collaborator

yozachar commented Oct 9, 2023

Hi @damianr13, we've fixed this in #305

~/test via 🐍 v3.11.5 (.venv) took 8s 
$ pip install --force git+https://github.com/python-validators/validators.git@$(git ls-remote https://github.com/python-validators/validators.git | head -1 | awk '{print $1;}')
Collecting git+https://github.com/python-validators/validators.git@15984e89a96ee8e8ceb9c2148cac6896a85cd71e
  Cloning https://github.com/python-validators/validators.git (to revision 15984e89a96ee8e8ceb9c2148cac6896a85cd71e) to /tmp/pip-req-build-r1m8t211
  Running command git clone --filter=blob:none --quiet https://github.com/python-validators/validators.git /tmp/pip-req-build-r1m8t211
  Running command git rev-parse -q --verify 'sha^15984e89a96ee8e8ceb9c2148cac6896a85cd71e'
  Running command git fetch -q https://github.com/python-validators/validators.git 15984e89a96ee8e8ceb9c2148cac6896a85cd71e
  Resolved https://github.com/python-validators/validators.git to commit 15984e89a96ee8e8ceb9c2148cac6896a85cd71e
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: validators
  Building wheel for validators (pyproject.toml) ... done
  Created wheel for validators: filename=validators-0.22.0-py3-none-any.whl size=26095 sha256=aa9eb59aa67fc5d06e7e3095b57b861af595b6e9ddcc4993a5bbd5b0226b5d66
  Stored in directory: /home/us-er/.cache/pip/wheels/ab/5a/e4/9fba9af05948fb3222e3f888b2d904f8428bc0cc03dbd260ec
Successfully built validators
Installing collected packages: validators
  Attempting uninstall: validators
    Found existing installation: validators 0.22.0
    Uninstalling validators-0.22.0:
      Successfully uninstalled validators-0.22.0
Successfully installed validators-0.22.0

~/test via 🐍 v3.11.5 (.venv) took 11s 
$ python                                
Python 3.11.5 (main, Sep  2 2023, 14:16:33) [GCC 13.2.1 20230801] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import validators
>>> validators.url("https://services.odata.org/OData/OData.svc/Products?$skip=2&$top=2&$orderby=Rating")
True

Also ref: https://python-validators.github.io/validators/reference/url/ (strict_query parameter)

@yozachar yozachar added bug Issue: Works not as designed addressed labels Oct 9, 2023
@yozachar yozachar linked a pull request Oct 9, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue: Works not as designed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants