directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r696620 - in /directory/shared/trunk/ldap/src: main/java/org/apache/directory/shared/ldap/name/RdnParser.java test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java test/java/org/apache/directory/shared/ldap/name/RdnTest.java
Date Thu, 18 Sep 2008 10:09:31 GMT
Author: elecharny
Date: Thu Sep 18 03:09:30 2008
New Revision: 696620

URL: http://svn.apache.org/viewvc?rev=696620&view=rev
Log:
Applied Norval's patches for DIRSERVER-1256

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java?rev=696620&r1=696619&r2=696620&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java
Thu Sep 18 03:09:30 2008
@@ -1069,11 +1069,14 @@
      */
     public static void parse( String dn, Rdn rdn ) throws InvalidNameException
     {
-        parse( StringTools.getBytesUtf8( dn ), new Position(), rdn );
+        if ( parse( StringTools.getBytesUtf8( dn ), new Position(), rdn ) == DNUtils.PARSING_ERROR
)
+        {
+            throw new InvalidNameException( "The RDN can't be parsed." );
+        }
     }
 
     /**
-     * Validtae a NameComponent : <br>
+     * Validate a NameComponent : <br>
      * <p>
      * &lt;name-component&gt; ::= &lt;attributeType&gt; &lt;spaces&gt;
'='
      * &lt;spaces&gt; &lt;attributeValue&gt; &lt;nameComponents&gt;

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java?rev=696620&r1=696619&r2=696620&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java
Thu Sep 18 03:09:30 2008
@@ -20,6 +20,7 @@
 package org.apache.directory.shared.ldap.name;
 
 
+import javax.naming.InvalidNameException;
 import javax.naming.Name;
 import javax.naming.NameParser;
 import javax.naming.NamingException;
@@ -203,6 +204,28 @@
 
 
     /**
+     * test exception from illegal hexString attribute value : a=#zz.
+     */
+    public void testBadLdapDNHexStringAttributeValue() throws InvalidNameException
+    {
+        try
+        {
+            NameParser dnParser = LdapDnParser.getNameParser();
+            dnParser.parse( "a=#zz" );
+            fail();
+        }
+        catch ( InvalidNameException ine )
+        {
+            assertTrue( true );
+        }
+        catch ( NamingException ine )
+        {
+            fail();
+        }
+    }
+    
+    
+    /**
      * test a simple DN with quoted attribute value : a = "quoted \"value"
      */
     public void testLdapDNQuotedAttributeValue() throws NamingException

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java?rev=696620&r1=696619&r2=696620&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java
Thu Sep 18 03:09:30 2008
@@ -232,6 +232,22 @@
         assertEquals( "a=#0010A0AAFF", new Rdn( "a = #0010A0AAFF" ).toString() );
     }
 
+    /**
+     * test exception from illegal hexString attribute value : a=#zz.
+     */
+    @Test
+    public void testBadRdnHexStringAttributeValue() throws InvalidNameException
+    {
+        try
+        {
+            new Rdn( "a=#zz" );
+            fail();
+        }
+        catch ( InvalidNameException ine )
+        {
+            assertTrue( true );
+        }
+    }
 
     /**
      * test a simple RDN with quoted attribute value : a = "quoted \"value"



Mime
View raw message