troll icon indicating copy to clipboard operation
troll copied to clipboard

fix: ensure valid Sec-WebSocket-Protocol

Open kmohrf opened this issue 3 years ago • 4 comments

Hi,

The WebSocket RFC requires in section 4.1 item 10 for the Sec-WebSocket-Protocol header that

If present, this value indicates one or more comma-separated subprotocol the client wishes to speak [...]

Strict implementations like the popular Node.js library ws follow that definition to the letter and abort the handshake, if the Sec-WebSocket-Protocol header is set but empty. Ideally, soup should reject an empty list of protocols or handle it gracefully but unfortunately does neither.

Thank you for your time!

Konrad

kmohrf avatar Nov 11 '22 17:11 kmohrf

I’ve also created an issue for libsoup.

kmohrf avatar Nov 11 '22 17:11 kmohrf

I’m currenty waiting for the related merge request to be merged, that will change how libsoup handles an empty protocol list.

This PR might be redundant afterwards.

kmohrf avatar Nov 22 '22 01:11 kmohrf

@kmohrf looks like https://gitlab.gnome.org/GNOME/libsoup/-/merge_requests/332 was closed

This can be closed, right?

sonnyp avatar Dec 17 '22 19:12 sonnyp

I haven’t tested the current implementation in libsoup yet, because they haven’t released any new versions since the merge. Depending on how they handle the empty protocols array, your WebSocket implementation might not be compatible, with the one documented in the standard. If you want to check that yourself feel free to close this PR. Otherwise, I’ll write me a note to check back on this PR in january with the hope that they’ve released a new version that made in into Archlinux by that time.

kmohrf avatar Dec 18 '22 16:12 kmohrf