Don't crash when parsing malformed JSON

This commit is contained in:
RobinLinus 2019-05-29 21:35:39 +02:00 committed by GitHub
parent 72bb4cba1f
commit 993b484396
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -26,7 +26,12 @@ class SnapdropServer {
}
_onMessage(sender, message) {
// Try to parse message
try {
message = JSON.parse(message);
} catch (e) {
return; // TODO: handle malformed JSON
}
switch (message.type) {
case 'disconnect':