From ee46d3f652feb9b756243eea3eadc0d30da30fb9 Mon Sep 17 00:00:00 2001
From: sin <sin@localhost>
Date: Fri, 10 Apr 2009 18:11:47 +0000
Subject: [PATCH] issue# 3445: Normalization of multi-valued RDNs

---
 opendj-sdk/opends/src/messages/messages/schema.properties                                |    7 +++++--
 opendj-sdk/opends/src/server/org/opends/server/types/DN.java                             |   22 ++++++++++++++++++++++
 opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/types/TestDN.java |    4 +++-
 3 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/opendj-sdk/opends/src/messages/messages/schema.properties b/opendj-sdk/opends/src/messages/messages/schema.properties
index e3304d5..19e80e5 100644
--- a/opendj-sdk/opends/src/messages/messages/schema.properties
+++ b/opendj-sdk/opends/src/messages/messages/schema.properties
@@ -20,7 +20,7 @@
 #
 # CDDL HEADER END
 #
-#      Copyright 2006-2008 Sun Microsystems, Inc.
+#      Copyright 2006-2009 Sun Microsystems, Inc.
 
 
 
@@ -916,4 +916,7 @@
  rule %s under matching rule entry %s is invalid as the locale %s is not supported \
  by JVM
 MILD_WARN_ATTR_INVALID_COLLATION_MATCHING_RULE_FORMAT_281=The provided \
- collation rule %s does not contain a valid format of OID:LOCALE
\ No newline at end of file
+ collation rule %s does not contain a valid format of OID:LOCALE
+MILD_ERR_ATTR_SYNTAX_DN_INVALID_REQUIRES_ESCAPE_CHAR_282=The provided \
+ value "%s" could not be parsed as a valid distinguished name because an \
+ attribute value started with a character at position %d that needs to be escaped
diff --git a/opendj-sdk/opends/src/server/org/opends/server/types/DN.java b/opendj-sdk/opends/src/server/org/opends/server/types/DN.java
index 953f864..16a832c 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/types/DN.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/types/DN.java
@@ -2220,6 +2220,17 @@
       return bs;
     }
 
+    else if(b == '+' || b == ',')
+    {
+      //We don't allow an empty attribute value. So do not allow the
+      // first character to be a '+' or ',' since it is not escaped
+      // by the user.
+      Message message =
+             ERR_ATTR_SYNTAX_DN_INVALID_REQUIRES_ESCAPE_CHAR.get(
+                      dnBytes.toString(),dnBytes.position());
+          throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX,
+                                       message);
+    }
 
     // Otherwise, use general parsing to find the end of the value.
     else
@@ -2448,6 +2459,17 @@
       attributeValue.append(valueString.toString());
       return pos;
     }
+    else if(c == '+' || c == ',')
+    {
+      //We don't allow an empty attribute value. So do not allow the
+      // first character to be a '+' or ',' since it is not escaped
+      // by the user.
+      Message message =
+             ERR_ATTR_SYNTAX_DN_INVALID_REQUIRES_ESCAPE_CHAR.get(
+                      dnString,pos);
+          throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX,
+                                       message);
+    }
 
 
     // Otherwise, use general parsing to find the end of the value.
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/types/TestDN.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/types/TestDN.java
index c74530a..b686927 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/types/TestDN.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/types/TestDN.java
@@ -147,7 +147,9 @@
         { "\u03c0=pi" },  { "v1.0=buggy" }, { "1.=buggy" }, { ".1=buggy" },
         { "oid.1." }, { "1.3.6.1.4.1.1466..0=#04024869" },
         { "cn=#a" }, { "cn=#ag" }, { "cn=#ga" }, { "cn=#abcdefgh" },
-        { "cn=a\\b" }, { "cn=a\\bg" }, { "cn=\"hello" } };
+        { "cn=a\\b" }, { "cn=a\\bg" }, { "cn=\"hello" },
+        {"cn=+mail=,dc=example,dc=com"},{"cn=xyz+sn=,dc=example,dc=com"},
+        {"cn=,dc=example,dc=com"}};
   }
 
 

--
Gitblit v1.10.0