fix(websocket): strip surrounding whitespace in parseExtensions - #5714
Open
arshsmith1 wants to merge 1 commit into
Open
fix(websocket): strip surrounding whitespace in parseExtensions#5714arshsmith1 wants to merge 1 commit into
arshsmith1 wants to merge 1 commit into
Conversation
Signed-off-by: arshiya tabasum <arshi@bugqore.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5714 +/- ##
=======================================
Coverage 93.47% 93.47%
=======================================
Files 110 110
Lines 38906 38906
=======================================
+ Hits 36366 36367 +1
+ Misses 2540 2539 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
This relates to...
N/A
Rationale
parseExtensionsinlib/web/websocket/util.jsstrips only leading whitespace from an extension parameter name and only trailing whitespace from its value:RFC 6455 section 9.1 defines
Sec-WebSocket-Extensionson the RFC 7230 header grammar, which allows optional whitespace around the;and=delimiters. A spec-valid response header therefore keeps whitespace on the untrimmed side of a token, and it lands inside the map key or value:The handshake then runs
extensions.has('permessage-deflate')inconnection.js, which isfalsebecause of the trailing space, and the connection is failed for a header the server was allowed to send. Parameter values have the mirror problem:PerMessageDeflatelooks upserver_max_window_bitsand getsundefined(the key carries a trailing space), and even where the key matches,isValidClientWindowBits(' 10')rejects the leading space. The window size the server negotiated is dropped.Only the whitespace handling is touched here; the wider section 9.1 work tracked by the existing TODO (comma-separated extension lists, quoted-string values) is left as is.
Changes
Trim whitespace from both ends of the parameter name and value in
parseExtensions.Features
N/A
Bug Fixes
parseExtensionsno longer retains delimiter-adjacent whitespace in extension parameter names and values, so validSec-WebSocket-Extensionsresponses that use optional whitespace around;/=negotiate correctly. Covered by a new case intest/websocket/util.js.Breaking Changes and Deprecations
N/A
Status