From ac5050f0f706b364c89b79975b2cbf309259f4fa Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 14 Aug 2013 17:44:41 -0700 Subject: [PATCH] Prevent accidental addition of cycles. --- guacamole/src/main/webapp/scripts/admin-ui.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/guacamole/src/main/webapp/scripts/admin-ui.js b/guacamole/src/main/webapp/scripts/admin-ui.js index 8c08bb18c..48a4ae90e 100644 --- a/guacamole/src/main/webapp/scripts/admin-ui.js +++ b/guacamole/src/main/webapp/scripts/admin-ui.js @@ -1022,9 +1022,22 @@ GuacAdmin.ConnectionGroupEditor = function(group, parameters) { document.body.appendChild(group_select.getElement()); // Update location when chosen - group_select.onselect = function(group) { - location_value = group; - location.textContent = group.name; + group_select.onselect = function(selected_group) { + + // Prevent selecting a situation that would produce a cycle + var current = selected_group; + while (current !== null) { + + if (current.id === group.id) { + alert("Cannot move a group into a subgroup of itself."); + return; + } + + current = current.parent; + } + + location_value = selected_group; + location.textContent = selected_group.name; }; };