Skip to content

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

Closed

Description

@damianr13

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

Activity

  1. nandgator commented on Oct 9, 2023

    @nandgator
    Collaborator

    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)

  2. linked a pull request that will close this issueFix fragment check #305on Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue: Works not as designed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions