mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2026-04-05 17:33:49 +00:00
Don't crash when parsing malformed JSON
This commit is contained in:
@@ -26,8 +26,13 @@ class SnapdropServer {
|
||||
}
|
||||
|
||||
_onMessage(sender, message) {
|
||||
message = JSON.parse(message);
|
||||
|
||||
// Try to parse message
|
||||
try {
|
||||
message = JSON.parse(message);
|
||||
} catch (e) {
|
||||
return; // TODO: handle malformed JSON
|
||||
}
|
||||
|
||||
switch (message.type) {
|
||||
case 'disconnect':
|
||||
this._leaveRoom(sender);
|
||||
@@ -221,4 +226,4 @@ class Peer {
|
||||
};
|
||||
}
|
||||
|
||||
const server = new SnapdropServer(process.env.PORT || 3000);
|
||||
const server = new SnapdropServer(process.env.PORT || 3000);
|
||||
|
||||
Reference in New Issue
Block a user