Skip to content

Match urlencoded parameter names in filter_post_data_parameters - #1066

Merged
kevin1024 merged 1 commit into
kevin1024:masterfrom
b84330808:fix-filter-post-data-encoded-names
Oct 25, 2026
Merged

kevin1024 merged 1 commit into
kevin1024:masterfrom
b84330808:fix-filter-post-data-encoded-names

Conversation

@b84330808

Copy link
Copy Markdown
Contributor

Fixes #686

filter_post_data_parameters compares the configured names against the raw bytes of a form body. Form bodies are urlencoded, so a parameter like api:key goes over the wire as api%3Akey (and user name as user+name, non-ASCII names as %XX sequences) and never matches. The value ends up in the cassette, which is what the filter is supposed to prevent.

This decodes the name with unquote_plus when the raw name isn't in the replacements and checks again. The raw name is still checked first, so anyone who worked around this by configuring api%3Akey keeps working. Values are left alone: a callable still gets the raw value and replacement values are written as given, same as before. Query parameter filtering already works on decoded names (it goes through parse_qsl), so this makes the two consistent.

I added unit tests for the decoded-name case (including a non-ASCII name and + for spaces) and for the already-encoded workaround, plus an integration test that records a urlencoded POST with filter_post_data_parameters=["api:key"].

This touches the same block as the open PRs for #660 (#1017, #1021, #1039, #1050) and #1004, so whichever lands second will need a small rebase.

I used Claude Code to write this change.

Form bodies percent-encode parameter names as well as values, so a
parameter such as "api:key" is sent as "api%3Akey" and was never matched
by filter_post_data_parameters=["api:key"], leaving the value in the
cassette. Fall back to the decoded name when the raw name doesn't match,
which keeps already-encoded names in existing configs working.

Fixes #686

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kevin1024 kevin1024 mentioned this pull request Oct 25, 2026
@kevin1024
kevin1024 merged commit 25fa4e2 into kevin1024:master Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

filter_post_data_parameters doesn't filter out parameters with non-ASCII chars

2 participants