directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r881973 - in /directory/shared/trunk/ldap/src: main/antlr/distinguishedName.g test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
Date Wed, 18 Nov 2009 22:38:49 GMT
Author: seelmann
Date: Wed Nov 18 22:38:49 2009
New Revision: 881973

URL: http://svn.apache.org/viewvc?rev=881973&view=rev
Log:
Fix for for DIRSTUDIO-589, DIRSTUDIO-591, DIRSHARED-38

Modified:
    directory/shared/trunk/ldap/src/main/antlr/distinguishedName.g
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java

Modified: directory/shared/trunk/ldap/src/main/antlr/distinguishedName.g
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/antlr/distinguishedName.g?rev=881973&r1=881972&r2=881973&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/antlr/distinguishedName.g (original)
+++ directory/shared/trunk/ldap/src/main/antlr/distinguishedName.g Wed Nov 18 22:38:49 2009
@@ -73,14 +73,16 @@
 protected DIGIT : '0'..'9' ;
 protected ALPHA : 'a'..'z' ;
 
-HEXPAIR_OR_ESCESC_OR_ESC 
+HEXPAIR_OR_ESCESC_ESCSHARP_OR_ESC 
     : (ESC HEX HEX) => HEXPAIR { $setType(HEXPAIR); }
     | ESCESC { $setType(ESCESC); }
+    | ESCSHARP { $setType(ESCSHARP); }
     | ESC { $setType(ESC); }
     ;
 protected HEXPAIR : ESC! HEX HEX ;
 protected ESC : '\\';
 protected ESCESC : ESC ESC;
+protected ESCSHARP : ESC SHARP;
 protected HEX: DIGIT | 'a'..'f' ;
 
 HEXVALUE_OR_SHARP
@@ -431,7 +433,7 @@
         dq1:DQUOTE { value.upValue += dq1.getText(); }
         (
             (
-                s:~(DQUOTE|ESC|ESCESC|HEXPAIR) 
+                s:~(DQUOTE|ESC|ESCESC|ESCSHARP|HEXPAIR) 
                 {
                     value.upValue += s.getText();
                     bb.append( StringTools.getBytesUtf8( s.getText() ) ); 
@@ -659,6 +661,14 @@
         } 
     )
     |
+    (
+        ESCSHARP 
+        { 
+            value.upValue += "\\#";
+            pair = StringTools.getBytesUtf8( "#" );
+        } 
+    )
+    |
     ( 
         ESC { value.upValue += "\\"; }
         tmp = special 

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java?rev=881973&r1=881972&r2=881973&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
Wed Nov 18 22:38:49 2009
@@ -358,6 +358,36 @@
 
 
     /**
+     * Test for DIRSTUDIO-589, DIRSTUDIO-591, DIRSHARED-38 
+     * 
+     * Check escaped sharp followed by a hex sequence
+     * (without the ESC it would be a valid hexstring).
+     */
+    @Test
+    public void testLdapDNEscSharpNumber() throws InvalidNameException, NamingException
+    {
+        LdapDN dn = new LdapDN( "a = \\#123456" );
+
+        assertTrue( LdapDN.isValid( "a = \\#123456" ) );
+        assertEquals( "a=\\#123456", dn.toString() );
+        assertEquals( "a = \\#123456", dn.getUpName() );
+
+        Rdn rdn = dn.getRdn();
+        assertEquals( "a = \\#123456", rdn.getUpName() );
+
+        assertTrue( LdapDN.isValid( "a = \\#00" ) );
+        assertTrue( LdapDN.isValid( "a = \\#11" ) );
+        assertTrue( LdapDN.isValid( "a = \\#99" ) );
+        assertTrue( LdapDN.isValid( "a = \\#AA" ) );
+        assertTrue( LdapDN.isValid( "a = \\#FF" ) );
+
+        assertTrue( LdapDN.isValid( "uid=\\#123456" ) );
+        assertTrue( LdapDN.isValid( "cn=\\#ACL_AD-Projects_Author,ou=Notes_Group,o=Contacts,c=DE"
) );
+        assertTrue( LdapDN.isValid( "cn=\\#Abraham" ) );
+    }
+
+
+   /**
      * test a simple DN with a # on first position
      */
     @Test



Mime
View raw message