FE: more defensive network topology hierarchy check #1308

Signed-off-by: jokob-sk <jokob.sk@gmail.com>
This commit is contained in:
jokob-sk
2025-11-30 10:55:08 +11:00
parent e0e1233b1c
commit 82e018e284

View File

@@ -521,12 +521,16 @@ function getChildren(node, list, path, visited = [])
// Loop through all items to find children of the current node // Loop through all items to find children of the current node
for (var i in list) { for (var i in list) {
if (list[i].devParentMAC.toLowerCase() == node.devMac.toLowerCase() && !hiddenMacs.includes(list[i].devParentMAC)) { const item = list[i];
const parentMac = item.devParentMAC || ""; // null-safe
const nodeMac = node.devMac || ""; // null-safe
if (parentMac != "" && parentMac.toLowerCase() == nodeMac.toLowerCase() && !hiddenMacs.includes(parentMac)) {
visibleNodesCount++; visibleNodesCount++;
// Process children recursively, passing a copy of the visited list // Process children recursively, passing a copy of the visited list
children.push(getChildren(list[i], list, path + ((path == "") ? "" : '|') + list[i].devParentMAC, visited)); children.push(getChildren(list[i], list, path + ((path == "") ? "" : '|') + parentMac, visited));
} }
} }