Skip to content

Conversation

@egangi
Copy link

@egangi egangi commented Nov 9, 2025

This PR fixes a bug in Requests where cookie values containing escaped quotes were being corrupted according to issue #6890.

Problem:

  • The original set_cookie method stripped all escaped quotes inside cookie values.
  • Example: '"159\"687"' became '159687', breaking valid cookie data, including JSON fragments or structured data.

Solution:

  • Modified set_cookie to only remove surrounding quotes while preserving escaped quotes within the value.
  • This preserves legitimate escaped characters and maintains compatibility with normal cookies.

Tests / QA:

  • test_cookie_escaped_quotes — Verifies that escaped quotes are preserved.
  • test_cookie_no_quotes — Ensures values without surrounding quotes but containing escaped quotes remain unchanged.
  • test_cookie_no_escaped_quotes — Confirms normal cookie values are stored as-is.
  • test_cookie_json_fragment — Checks that JSON fragments with escaped quotes are preserved exactly.
  • All existing Requests tests pass, and pre-commit hooks and style checks are satisfied.
@egangi egangi marked this pull request as ready for review November 10, 2025 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant