Repository navigation
Reject WebSocket protocols that repeat in a different case - #8844
Conversation
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.
There was a problem hiding this comment.
✅ 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
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_extensionsis 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.