TypeFox/vscode-ws-jsonrpc

Reader doesn't handle binary data

emccorson opened this issue · 0 comments

If a message is received with binary data, the client will crash at this line:

const data = JSON.parse(message);

readMessage assumes that message is a string but it could also be binary data.

According to the WebSocket specification, the payload can be binary data depending on the opcode of the frame received:

   Opcode:  4 bits

      Defines the interpretation of the "Payload data".  If an unknown
      opcode is received, the receiving endpoint MUST _Fail the
      WebSocket Connection_.  The following values are defined.

      *  %x0 denotes a continuation frame

      *  %x1 denotes a text frame

      *  %x2 denotes a binary frame

      *  %x3-7 are reserved for further non-control frames

      *  %x8 denotes a connection close

      *  %x9 denotes a ping

      *  %xA denotes a pong

      *  %xB-F are reserved for further control frames

(https://datatracker.ietf.org/doc/rfc6455/)