From 3f4deb91789189521d577457bd6da27de8fd75b1 Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Wed, 07 Oct 2026 08:31:10 +0000
Subject: [PATCH] [#1153] Parse the whole DN string, and build or split DN strings through DN instead of string operations (#1171)

---
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
index bd73b3c..a2edca8 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
@@ -1280,6 +1280,38 @@
   }
 
   /**
+   * Returns the DN of the configuration entry of a backend. The backend ID becomes the value of the RDN, so it may
+   * hold any character, a ',' for instance.
+   *
+   * @param backendID
+   *          the ID of the backend
+   * @return the DN of the configuration entry of the backend
+   */
+  public static DN getBackendConfigDN(String backendID)
+  {
+    return DN.valueOf(ConfigConstants.DN_BACKEND_BASE).child(ConfigConstants.ATTR_BACKEND_ID, backendID);
+  }
+
+  /**
+   * Returns the DN of the configuration entry of an index. The backend ID and the index name become the values of
+   * RDNs, so they may hold any character.
+   *
+   * @param backendID
+   *          the ID of the backend of the index
+   * @param indexName
+   *          the name of the index: the attribute of an attribute index, the name of a VLV index
+   * @param isVLVIndex
+   *          whether the index is a VLV index
+   * @return the DN of the configuration entry of the index
+   */
+  public static DN getIndexConfigDN(String backendID, String indexName, boolean isVLVIndex)
+  {
+    final DN backendDN = getBackendConfigDN(backendID);
+    return isVLVIndex ? backendDN.child("cn", "VLV Index").child("ds-cfg-name", indexName)
+                      : backendDN.child("cn", "Index").child("ds-cfg-attribute", indexName);
+  }
+
+  /**
    * Unescapes UTF-8 text and generates a String from it.
    * @param v the string in UTF-8 format.
    * @return the string with unescaped characters.
@@ -1294,6 +1326,14 @@
       for (int i = 0; i < stringBytes.length; i++)
       {
         if (stringBytes[i] == '\\'
+                && i + 1 < stringBytes.length
+                && stringBytes[i+1] == '\\')
+        {
+          // An escaped backslash: the character after it does not start a hex pair.
+          decodedBytes[pos++] = stringBytes[i++];
+          decodedBytes[pos++] = stringBytes[i];
+        }
+        else if (stringBytes[i] == '\\'
                 && i + 2 < stringBytes.length
                 && StaticUtils.isHexDigit(stringBytes[i+1])
                 && StaticUtils.isHexDigit(stringBytes[i+2]))

--
Gitblit v1.10.0