Tcl Library Source Code

View Ticket
Login
Ticket UUID: 0bd02c1bf804786a500d8a2abc1dceed826c26ca
Title: websocket: sec-websocket-protocol is optional but checked in websocket::test
Type: Bug Version: 1.18
Submitter: ecky-l Created on: 2016-11-20 14:42:07
Subsystem: websocket Assigned To: emmanuel
Priority: 5 Medium Severity: Severe
Status: Open Last Modified: 2016-12-16 16:51:31
Resolution: None Closed By: nobody
    Closed on:
Description:
According to the websocket RFC, the sec-websocket-protocol header is optional for additional protocols on top of websocket. 

The websocket::validate ($headers) proc does not set the "protocols" dict entry, if no sec-websocket-protocol header is present. But websocket::test assumes that the "protocols" entry is always present.

Line 492: set protos [dict get $res protocols]

It can be worked around if no sec-websocket-protocol is present, by changing that line 492 to:

set protos [expr { ([dict exists $res protocols]) ? [dict get $res protocols] : [list *] }]

to install a handler for all protocols. Is this a viable fix?