From 3822216329d7d2f2dae2b1d3cc95cdac56e7ea0f Mon Sep 17 00:00:00 2001 From: boavenn Date: Tue, 22 Oct 2024 14:04:29 +0100 Subject: [PATCH] Ignore escaped commas when parsing active directory DNs (#245) --- .../config/ad/ActiveDirectoryUtils.java | 3 ++- .../config/ad/tree/ActiveDirectoryNode.java | 3 ++- .../config/ad/tree/ActiveDirectoryTree.java | 3 ++- .../ActiveDirectoryUserLeaderProvider.java | 4 ++- .../config/ad/ActiveDirectoryUtilsTest.groovy | 27 ++++++++++--------- 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/main/java/info/fingo/urlopia/config/ad/ActiveDirectoryUtils.java b/src/main/java/info/fingo/urlopia/config/ad/ActiveDirectoryUtils.java index 4394752..367b83c 100644 --- a/src/main/java/info/fingo/urlopia/config/ad/ActiveDirectoryUtils.java +++ b/src/main/java/info/fingo/urlopia/config/ad/ActiveDirectoryUtils.java @@ -56,7 +56,8 @@ public static String getRelativeDN(String distinguishedName, } public static String getParentDN(String distinguishedName) { - var dnParts = Arrays.stream(distinguishedName.split(",")).toList(); + var commasIgnoringEscapedRegex = "(? getDirectChildrenObjects() { diff --git a/src/main/java/info/fingo/urlopia/config/ad/tree/ActiveDirectoryTree.java b/src/main/java/info/fingo/urlopia/config/ad/tree/ActiveDirectoryTree.java index 706c212..3b832ff 100644 --- a/src/main/java/info/fingo/urlopia/config/ad/tree/ActiveDirectoryTree.java +++ b/src/main/java/info/fingo/urlopia/config/ad/tree/ActiveDirectoryTree.java @@ -48,7 +48,8 @@ private Optional searchNode(String distinguishedName) { if (relativeDn.isBlank()) { return Optional.of(root); } - var dnParts = Arrays.stream(relativeDn.split(",")).toList(); + var commasIgnoringEscapedRegex = "(? extractOrganizationalUnitsDNs(String distinguishedName) { var result = new ArrayList(); - var components = distinguishedName.split(","); + var commasIgnoringEscapedRegex = "(?