Skip to content

urllib.parse.parse_qs should not parse a query string containing illegal characters #135523

Open
@declaresub

Description

@declaresub

Bug report

Bug description:

urllib.parse.parse_qsl will happily parse a query string containing '#'.

from urllib.parse import parse_qsl
parse_qsl('foo=#', strict_parsing=True)

Output is [('foo', '#')] .

But 'foo=#' is an invalid query string according to RFC 3986. Similarly, '[', and ']' are excluded from the set of valid query characters, but parse_qsl parses strings like 'foo=[' and 'foo=]' . In the absence of any allocation of responsibility, this looks like a bug to me.

CPython versions tested on:

3.13

Operating systems tested on:

macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions