fix: avoid double-spacing inconsistently delimited BiDi cookies#34207
Open
anxkhn wants to merge 2 commits into
Open
fix: avoid double-spacing inconsistently delimited BiDi cookies#34207anxkhn wants to merge 2 commits into
anxkhn wants to merge 2 commits into
Conversation
Collaborator
|
Member
|
@anxkhn Add a changelog entry please |
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.
a5711d1 to
75a6953
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Additional details
FormatCookiesIfApplicableinpackages/proxy/lib/http/request-middleware.tsnormalizes WebDriver BiDi cookie headers (which arrive asfoo=bar;bar=baz) to;-delimited form. It did so with:When the header is delimited inconsistently (some pairs already spaced), this also expands the correct
;into;(double space). For examplefoo=bar; bar=baz;qux=quuxbecomesfoo=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
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
cypress-documentation?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
FormatCookiesIfApplicablewhen the proxy forwards requests marked withx-cypress-is-webdriver-bidi.Normalization no longer uses
replaceAll(';', '; '), which turned already-spaced;into;when the header mixed spaced and unspaced semicolons. It now usesreplace(/;\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.