Skip to content

Match cookies whose value contains '=' - #235

Merged
pimterry merged 2 commits into
httptoolkit:mainfrom
bardrop-oss:fix-cookie-value-equals
Nov 24, 2026
Merged

pimterry merged 2 commits into
httptoolkit:mainfrom
bardrop-oss:fix-cookie-value-equals

Conversation

@bardrop

@bardrop bardrop commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

withCookie() splits each cookie on every = and keeps only the first two parts, so a value that contains = is cut. Cookie: session=YWJjZA== is compared as YWJjZA:

  • .withCookie({ session: 'YWJjZA==' }) never matches
  • .withCookie({ session: 'YWJjZA' }) matches when it should not

This is common with base64 session cookies and signed cookies. The name and value are now split on the first = only, which is how RFC 6265 section 5.2 parses them.

I added two cases to cookie-matching.spec.ts (full value matches, truncated value does not). The first fails without the change. The node matcher tests all pass (124); I didn't run the browser build.

CookieMatcher split each cookie on every '=', so base64 cookies like session=YWJjZA== were compared as 'YWJjZA' and never matched.
@CLAassistant

CLAassistant commented Nov 23, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@pimterry pimterry left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One small point on the tests, and the CLA needs signing @bardrop

@bardrop

bardrop commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@pimterry signed the CLA. Can you please review this when you have some time.

@pimterry
pimterry merged commit cb4bb1a into httptoolkit:main Nov 24, 2026
10 checks passed
@pimterry

Copy link
Copy Markdown
Member

Merged, thanks @bardrop! Will release shortly with some other changes I'm working on.

By the way, in case you're not aware, HTTP Toolkit Pro is free for all contributors to all https://github.com/httptoolkit repos. If that would be useful, just let me know your email (either here or by sending a message to opensource @ httptoolkit.com) and I'll set you up with an account.

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.

3 participants