Skip to content

Use ASCII group separator (GS) for separating key/value in caching middleware - #68510

Merged
Youssef1313 merged 1 commit into
mainfrom
dev/ygerges/cache-middleware
Aug 14, 2026
Merged

Youssef1313 merged 1 commit into
mainfrom
dev/ygerges/cache-middleware

Conversation

@Youssef1313

Copy link
Copy Markdown
Member

Fixes #67760

Copilot AI lite review requested due to automatic review settings August 14, 2026 07:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This pull request updates the ResponseCaching vary-key serialization to avoid cache-key collisions when decoded header/query names or values legitimately contain =. It switches the structural name/value separator from a literal = to the ASCII Group Separator control character (\x1d), and expands validation/tests accordingly.

Changes:

  • Replaced the = name/value separator in the response-caching vary key with \x1d (GS) to make key serialization unambiguous.
  • Extended delimiter validation to reject the new name/value delimiter character.
  • Updated and added unit tests covering the new delimiter and the prior =-collision scenario in wildcard query-key mode.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Middleware/ResponseCaching/src/ResponseCachingKeyProvider.cs Uses \x1d as the name/value separator and rejects it via ThrowIfContainsDelimiters to prevent collisions.
src/Middleware/ResponseCaching/test/ResponseCachingKeyProviderTests.cs Updates expected key strings to use the new separator and adds regression coverage for the encoded-= collision case.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@Youssef1313 Youssef1313 changed the title Use ASCII group separate (GS) for separating key/value in caching middleware Use ASCII group separator (GS) for separating key/value in caching middleware Aug 14, 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.

ResponseCaching: VaryByQueryKeys vary key can collide because the '=' name/value separator is not escaped

3 participants