Skip to content

Document that querystring values are not unquoted twice - #4209

Merged
petyaslavova merged 3 commits into
redis:masterfrom
winklemad:fix/parse-url-query-double-decode-c2
Aug 3, 2026
Merged

Document that querystring values are not unquoted twice#4209
petyaslavova merged 3 commits into
redis:masterfrom
winklemad:fix/parse-url-query-double-decode-c2

Conversation

@winklemad

@winklemad winklemad commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Description of change

urllib.parse.parse_qs already percent-decodes query values. Both the sync and
async URL parsers subsequently called unquote on those values, causing
doubly encoded data such as %2520 to become a space instead of the literal
%20.

Remove the redundant second decoding step in both implementations and add
mirrored sync/async regression tests proving query values are decoded exactly
once.

Fixes #4208

Pull Request check-list

Please make sure to review and check all of these items:

  • Do tests and lints pass with this change?
    • Focused tests, all 83 URL-parsing tests, Ruff checks and formatting for
      changed files, and full Vulture pass.
    • The repository-wide formatter check reports three pre-existing unrelated
      files on master.
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
    • CI has not run yet.
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
    • Not applicable; no public API is modified.
  • Is there an example added to the examples folder (if applicable)?
    • Not applicable.

NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.


Note

Low Risk
Doc-only changes to public API descriptions; no runtime behavior in the shown diff.

Overview
Updates from_url / ConnectionPool.from_url docstrings in sync and async client, cluster, and connection modules so they match actual URL parsing behavior.

The docs no longer say querystring values are passed through urllib.parse.unquote. They now state that username, password, hostname, and path are unquoted, while query parameters are decoded once by parse_qs and are not unquoted again—avoiding the misleading impression of double-decoding (e.g. %2520 becoming a space instead of %20, per #4208).

Reviewed by Cursor Bugbot for commit ed28558. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread redis/connection.py
@Sanjays2402

Copy link
Copy Markdown
Contributor

the from_url docstrings still promise the old behaviour: "The username, password, hostname, path and all querystring values are passed through urllib.parse.unquote" (client.py:194, connection.py:2938, cluster.py:669, plus the three asyncio twins). querystring values are the one item in that list that no longer goes through unquote after this, so it should probably be dropped from the sentence.

parse_qs already percent-decodes query values, so from_url does not pass
them through unquote a second time. The docstrings still listed them
alongside username, password, hostname and path.
@winklemad
winklemad force-pushed the fix/parse-url-query-double-decode-c2 branch from 6a5dbf3 to abc7b06 Compare August 2, 2026 07:28
@winklemad winklemad changed the title Fix double decoding of URL query values Document that querystring values are not unquoted twice Aug 2, 2026
@winklemad

Copy link
Copy Markdown
Contributor Author

You're right, and thanks for the precise pointers — I'd missed that the sentence wraps across two lines.

Since #4222 landed the actual fix on master, I've narrowed this PR down to just the docs half, which is the part still outstanding. All six from_url docstrings now read that username/password/hostname/path go through unquote, and that querystring values are decoded by parse_qs and not unquoted again. No code or test changes left — those are upstream's now, so the branch is conflict-free against master again.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: abc7b062aa

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread redis/connection.py
@petyaslavova petyaslavova added the maintenance Maintenance (CI, Releases, etc) label Aug 3, 2026

@petyaslavova petyaslavova left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @winklemad, thank you for your contribution! The change LGTM.

@petyaslavova
petyaslavova merged commit d07abe3 into redis:master Aug 3, 2026
730 of 731 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Maintenance (CI, Releases, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

URL query values are percent-decoded twice

3 participants