From 82e018e2841aecc422a982333d03b912fe06415c Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Sun, 30 Nov 2025 10:55:08 +1100 Subject: [PATCH] FE: more defensive network topology hierarchy check #1308 Signed-off-by: jokob-sk --- front/network.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/front/network.php b/front/network.php index afdc5c3b..a7925bf3 100755 --- a/front/network.php +++ b/front/network.php @@ -521,13 +521,17 @@ function getChildren(node, list, path, visited = []) // Loop through all items to find children of the current node 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 - visibleNodesCount++; + if (parentMac != "" && parentMac.toLowerCase() == nodeMac.toLowerCase() && !hiddenMacs.includes(parentMac)) { - // Process children recursively, passing a copy of the visited list - children.push(getChildren(list[i], list, path + ((path == "") ? "" : '|') + list[i].devParentMAC, visited)); - } + visibleNodesCount++; + + // Process children recursively, passing a copy of the visited list + children.push(getChildren(list[i], list, path + ((path == "") ? "" : '|') + parentMac, visited)); + } } // Track leaf and parent node counts