Skip to content

fix: avoid double-spacing inconsistently delimited BiDi cookies#34207

Open
anxkhn wants to merge 2 commits into
cypress-io:developfrom
anxkhn:fix/bidi-cookie-double-space
Open

fix: avoid double-spacing inconsistently delimited BiDi cookies#34207
anxkhn wants to merge 2 commits into
cypress-io:developfrom
anxkhn:fix/bidi-cookie-double-space

Conversation

@anxkhn

@anxkhn anxkhn commented Jul 2, 2026

Copy link
Copy Markdown
Contributor
  • Closes [na]

Additional details

FormatCookiesIfApplicable in packages/proxy/lib/http/request-middleware.ts normalizes WebDriver BiDi cookie headers (which arrive as foo=bar;bar=baz) to ; -delimited form. It did so with:

this.req.headers.cookie = cookies.replaceAll(';', '; ')

When the header is delimited inconsistently (some pairs already spaced), this also expands the correct ; into ; (double space). For example foo=bar; bar=baz;qux=quux becomes foo=bar; bar=baz; qux=quux.

This normalizes each delimiter to a single ; (replace(/;\s*/g, '; ')) so mixed input is handled without double-spacing.

Steps to test

yarn workspace @packages/proxy test -- test/unit/http/request-middleware.spec.ts

A regression test covers the inconsistently-delimited case (red->green); existing tests for no-header, already-formatted, and fully-unspaced cookies still pass.

How has the user experience changed?

No visible behavior change; BiDi cookie headers forwarded by the proxy are normalized to single-spaced delimiters instead of occasionally double-spaced.

PR Tasks

  • [na] Is there an associated issue with maintainer approval for PR submission?
  • Have tests been added/updated?
  • [na] Has a PR for user-facing changes been opened in cypress-documentation?
  • [na] Have API changes been updated in the type definitions?

Note

Low Risk
Small proxy middleware string change for BiDi-only cookie headers, with a regression test and no user-facing API changes.

Overview
Fixes WebDriver BiDi cookie header normalization in FormatCookiesIfApplicable when the proxy forwards requests marked with x-cypress-is-webdriver-bidi.

Normalization no longer uses replaceAll(';', '; '), which turned already-spaced ; into ; when the header mixed spaced and unspaced semicolons. It now uses replace(/;\s*/g, '; ') so every delimiter becomes a single ; .

A unit test covers the mixed-delimiter case, and the changelog documents the fix for 15.18.1.

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

@anxkhn anxkhn requested a deployment to fork-pr-review July 2, 2026 07:06 — with GitHub Actions Waiting
@anxkhn anxkhn requested a deployment to fork-pr-review July 2, 2026 07:06 — with GitHub Actions Waiting
@anxkhn anxkhn requested a deployment to fork-pr-review July 2, 2026 07:06 — with GitHub Actions Waiting
@cursor cursor Bot requested a deployment to fork-pr-review July 2, 2026 07:07 Waiting
@cypress-app-bot

Copy link
Copy Markdown
Collaborator

@jennifer-shehane

Copy link
Copy Markdown
Member

@anxkhn Add a changelog entry please

anxkhn added 2 commits July 7, 2026 22:08
When only some cookie pairs lacked a space after the delimiter,
`replaceAll(';', '; ')` also expanded the already-correct `; ` into `;  `.
Normalize each delimiter to a single `; ` instead.
@anxkhn anxkhn force-pushed the fix/bidi-cookie-double-space branch from a5711d1 to 75a6953 Compare July 7, 2026 16:43
@anxkhn anxkhn requested a deployment to fork-pr-review July 7, 2026 16:43 — with GitHub Actions Waiting
@anxkhn anxkhn requested a deployment to fork-pr-review July 7, 2026 16:43 — with GitHub Actions Waiting
@anxkhn anxkhn requested a deployment to fork-pr-review July 7, 2026 16:43 — with GitHub Actions Waiting
@cursor cursor Bot requested a deployment to fork-pr-review July 7, 2026 16:43 Waiting
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