Repository navigation
websocket: Fix uncaught exception in extension parsing - #3940
Merged
bdarnell merged 2 commits intoNov 27, 2026
Merged
Conversation
accept_connection handles ValueError from _accept_connection by calling _abort(), but before the stream is detached that fails with AttributeError in close(), producing a 500 and a logged traceback. One way to reach it is a permessage-deflate parameter in RFC 2231 form whose decoded value contains a newline: it is echoed in Sec-WebSocket-Extensions and set_header rejects it. Now a ValueError before the upgrade sends a 400 response. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VamvWqd4dUJoMCufE5qJ3G
RFC 7692 section 5 requires the server to decline an offer with an invalid parameter value. _create_compressors only rejected unknown parameter names and window sizes that int() can't parse, so values like "+15", "1_5", "15\n" (via RFC 2231 encoding) and a value on *_no_context_takeover were accepted and echoed back in the response. A value containing a newline then failed in set_header, producing a 500. Now the no_context_takeover parameters must have no value and the max_window_bits values must be ASCII digits; anything else declines the offer (and, on the client, fails the connection, as the RFC also requires). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VamvWqd4dUJoMCufE5qJ3G
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.
No description provided.