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

urllib.parse.parse_qsl does not parse empty query string with strict parsing #90032

Open
sattlerc mannequin opened this issue Nov 22, 2021 · 3 comments
Open

urllib.parse.parse_qsl does not parse empty query string with strict parsing #90032

sattlerc mannequin opened this issue Nov 22, 2021 · 3 comments
Labels
3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@sattlerc
Copy link
Mannequin

sattlerc mannequin commented Nov 22, 2021

BPO 45874
Nosy @asvetlov, @sattlerc
PRs
  • bpo-45874: Handle empty query string correctly in urllib.parse.parse_qsl #29716
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2021-11-22.22:35:40.875>
    labels = ['type-bug', 'library', '3.10']
    title = 'urllib.parse.parse_qsl does not parse empty query string with strict parsing'
    updated_at = <Date 2021-12-12.08:41:19.198>
    user = 'https://github.com/sattlerc'

    bugs.python.org fields:

    activity = <Date 2021-12-12.08:41:19.198>
    actor = 'asvetlov'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2021-11-22.22:35:40.875>
    creator = 'sattler'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 45874
    keywords = ['patch']
    message_count = 2.0
    messages = ['406807', '408368']
    nosy_count = 3.0
    nosy_names = ['asvetlov', 'python-dev', 'sattler']
    pr_nums = ['29716']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue45874'
    versions = ['Python 3.10']

    @sattlerc
    Copy link
    Mannequin Author

    sattlerc mannequin commented Nov 22, 2021

    Calling
    urllib.parse.parse_qsl('', strict_parsing=True)
    yields an error:
    ValueError: bad query field: ''

    The empty string '' is produced by
    urllib.parse.urlencode({})
    and also as query string by
    urllib.parse.urlsplit('http://example.org/')
    so it should be accepted by urllib.parse.parse_qsl with strict parsing.

    The problem is that parse_qsl(qs, ...) cannot distinguish between zero and one query arguments. The call to qs.split(separator) returns the non-empty list [''] for qs empty, which means one query argument. However, in this case, we want the other semantics.

    @sattlerc sattlerc mannequin added 3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Nov 22, 2021
    @asvetlov
    Copy link
    Contributor

    New changeset e6fe10d by Christian Sattler in branch 'main':
    bpo-45874: Handle empty query string correctly in urllib.parse.parse_qsl (bpo-29716)
    e6fe10d

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @furkanonder
    Copy link
    Sponsor Contributor

    @asvetlov Issue seems to resolved. We can close the issue.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants