meetecho / janus-gateway

Janus WebRTC Server
https://janus.conf.meetecho.com
GNU General Public License v3.0
8.25k stars 2.48k forks source link

avoid parsing whitespace as invalid JSON #3208

Closed htrendev closed 1 year ago

htrendev commented 1 year ago

A single WebSocket message may contain multiple requests. The code parses one request, then continues looking for more requests in the same WebSocket message. This works fine as long as the last request has no trailing whitespace. However, if there is any trailing whitespace after the last request an attempt to parse it as JSON results in an error.

This PR simply skips any trailing whitespace after each request

januscla commented 1 year ago

Thanks for your contribution, @htrendev! Please make sure you sign our CLA, as it's a required step before we can merge this.

htrendev commented 1 year ago

CLA signed

lminiero commented 1 year ago

Apologies for the late feedback: just tested this and it seems to be working as expected :ok_hand: I'll merge both PRs, thanks for your contribution!