python / python/cpython

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

Open
#135,523 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

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

Linked PRs
  • gh-152530

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at urllib.parse.parse_qsl and review how query characters are validated against RFC 3986. Check the existing parsing tests and the linked PR gh-152530 first; done means illegal characters such as '#', '[' and ']' are handled consistently with the agreed behavior and covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.