Fixed user array type in MeshCore.
Ylian Saint-Hilaire committed
Nov 2, 2020 at 09:47 UTC
7f2bcbc919b081dc2d7125b9bd37e228ef83210e
3 files changed
+3
-3
agents/meshcore.js
+1
-1
@@ -3723,7 +3723,7 @@ function createMeshCore(agent) {
3723
if (x != LastPeriodicServerUpdate) { LastPeriodicServerUpdate = x; mesh.SendCommand(meshCoreObj); }
3724
}
3725
3726
- function sortObjRec(o) { if (typeof o != 'object') return o; for (var i in o) { if (typeof o[i] == 'object') { o[i] = sortObjRec(o[i]); } } return sortObj(o); }
3726
+ function sortObjRec(o) { if ((typeof o != 'object') || (Array.isArray(o))) return o; for (var i in o) { if (typeof o[i] == 'object') { o[i] = sortObjRec(o[i]); } } return sortObj(o); }
3727
function sortObj(o) { return Object.keys(o).sort().reduce(function (result, key) { result[key] = o[key]; return result; }, {}); }
3728
3729
// Starting function
meshagent.js
+1
-1
@@ -1466,7 +1466,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
1466
if ((command.av != null) && (JSON.stringify(device.av) != JSON.stringify(command.av))) { /*changes.push('AV status');*/ device.av = command.av; change = 1; log = 1; }
1467
}
1468
1469
- if ((command.users != null) && (device.users != command.users)) { device.users = command.users; change = 1; } // Don't save this to the db.
1469
+ if ((command.users != null) && (Array.isArray(command.users)) && (device.users != command.users)) { device.users = command.users; change = 1; } // Don't save this to the db.
1470
if ((mesh.mtype == 2) && (!args.wanonly)) {
1471
// In WAN mode, the hostname of a computer is not important. Don't log hostname changes.
1472
if (device.host != obj.remoteaddr) { device.host = obj.remoteaddr; change = 1; changes.push('host'); }
views/default.handlebars
+1
-1
@@ -3895,7 +3895,7 @@
3895
}
3896
3897
function getUserShortStr(node) {
3898
- if (node == null || node.users == null || node.users.length == 0) return '';
3898
+ if (node == null || node.users == null || (!Array.isArray(node.users)) || node.users.length == 0) return '';
3899
if (node.users.length > 1) { return '<span title="' + EscapeHtml(node.users.join(', ')) + '">' + nobreak(format("{0} users", node.users.length)) + '</span>'; }
3900
var u = node.users[0], su = u, i = u.indexOf('\\');
3901
if (i > 0) { su = u.substring(i + 1); }