fix: don't crash on objects with toString property

isekai-main
Barış Soner Uşaklı 2 years ago
parent 7397873db3
commit 4d2d76897a

@ -112,16 +112,18 @@ async function onMessage(socket, payload) {
return winston.warn('[socket.io] Empty payload');
}
const eventName = payload.data[0];
let eventName = payload.data[0];
const params = typeof payload.data[1] === 'function' ? {} : payload.data[1];
const callback = typeof payload.data[payload.data.length - 1] === 'function' ? payload.data[payload.data.length - 1] : function () {};
try {
if (!eventName) {
return winston.warn('[socket.io] Empty method name');
}
if (typeof eventName !== 'string') {
const escapedName = validator.escape(String(eventName));
eventName = typeof eventName;
const escapedName = validator.escape(eventName);
return callback({ message: `[[error:invalid-event, ${escapedName}]]` });
}
@ -153,7 +155,6 @@ async function onMessage(socket, payload) {
return socket.disconnect();
}
try {
await checkMaintenance(socket);
await validateSession(socket, '[[error:revalidate-failure]]');

Loading…
Cancel
Save