Skip to content

Reject WebSocket protocols that repeat in a different case - #8844

Merged
littledivy merged 2 commits into
mainfrom
littledivy/2026-11-23-wpt-ws-dup-protocols
Nov 24, 2026
Merged

littledivy merged 2 commits into
mainfrom
littledivy/2026-11-23-wpt-ws-dup-protocols

Conversation

@littledivy

Copy link
Copy Markdown
Member

The WebSocket constructor rejected repeated protocols with a SyntaxError, but compared them case-sensitively, so new WebSocket(url, ["echo", "Echo"]) sent both. The WebSockets spec and browsers treat these as repeats. The WPT case Create-protocols-repeated-case-insensitive failed because of this.

In this patch the duplicate check lowercases each protocol when websocket_standard_url_and_extensions is on. The header still carries the protocols as given. That flag already makes the constructor follow the WHATWG WebSockets spec and has no enable date, so only Workers that opt in see the new SyntaxError. Without the flag nothing changes.

websocket-standard-url-test gets a case for ["echo", "Echo"] with and without the flag, and the WPT expected failure is removed. Both fail without the fix.

The WebSocket constructor rejected repeated protocols with a SyntaxError,
but compared them case-sensitively, so `new WebSocket(url, ["echo",
"Echo"])` sent both. The WebSockets spec and browsers treat these as
repeats.

In this patch the duplicate check lowercases each protocol when
websocket_standard_url_and_extensions is on. The header still carries
the protocols as given. Without the flag nothing changes. The flag has
no enable date, so only Workers that opt in see the new SyntaxError.
@littledivy
littledivy requested review from a team as code owners November 24, 2026 03:08

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Approved — This is a small, flag-gated fix for spec conformance, with tests for both the flagged and unflagged paths. No issues found.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

Every protocol token is still validated before use, and the header is built from the validated original strings. The change opens no new injection path.


📋 Code Quality: ✅ LGTM

The case-insensitive duplicate check is correct and runs only under the flag. The header keeps the protocols as given. The tests cover both the flagged and unflagged workers, and the WPT target enables the flag.


📝 Documentation: ✅ LGTM

The added note on the compatibility flag accurately describes the new behaviour.


Reviewed commit: f47de1f5

@littledivy
littledivy merged commit 28068ef into main Nov 24, 2026
24 checks passed
@littledivy
littledivy deleted the littledivy/2026-11-23-wpt-ws-dup-protocols branch November 24, 2026 03:38
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.

2 participants