directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r377914 - in /directory/sandbox/akarasulu/rc1/shared/ldap/src: main/java/org/apache/directory/shared/ldap/name/LdapDnParser.java test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java
Date Wed, 15 Feb 2006 01:34:32 GMT
Author: elecharny
Date: Tue Feb 14 17:34:30 2006
New Revision: 377914

URL: http://svn.apache.org/viewcvs?rev=377914&view=rev
Log:
Fixed the DN parser to handle special DNs like those
presented in  DIRSERVER-578

Modified:
    directory/sandbox/akarasulu/rc1/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDnParser.java
    directory/sandbox/akarasulu/rc1/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java

Modified: directory/sandbox/akarasulu/rc1/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDnParser.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDnParser.java?rev=377914&r1=377913&r2=377914&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDnParser.java
(original)
+++ directory/sandbox/akarasulu/rc1/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDnParser.java
Tue Feb 14 17:34:30 2006
@@ -126,7 +126,14 @@
                     && ( StringTools.isCharASCII( chars, pos, ';' ) == false ) )
                 {
 
-                    break;
+                    if ( pos != chars.length )
+                    {
+                        throw new InvalidNameException( "Bad DN : " + new String( chars )
);
+                    }
+                    else
+                    {
+                        break;
+                    }
                 }
 
                 chars[pos] = ',';

Modified: directory/sandbox/akarasulu/rc1/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java?rev=377914&r1=377913&r2=377914&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java
(original)
+++ directory/sandbox/akarasulu/rc1/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java
Tue Feb 14 17:34:30 2006
@@ -522,4 +522,30 @@
         assertEquals( cn, result.toString() );
 
     }
+
+    /**
+     * Test to check that even with a non escaped char, the DN is parsed ok
+     * or at least an error is generated. 
+     * 
+     * @throws NamingException
+     *             if anything goes wrong on parse()
+     */
+    public final void testNonEscapedChars() throws NamingException
+    {
+        NameParser parser = LdapDnParser.getNameParser();
+        String input = "ou=ou=test";
+        
+        try
+        {
+            parser.parse( input ).toString();
+        }
+        catch ( NamingException ne )
+        {
+            assertTrue( true );
+            return;
+        }
+        
+        fail( "Should never rech this point" );
+    }
+
 }



Mime
View raw message