You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2009/11/23 21:57:00 UTC
svn commit: r883499 - in /directory/shared/trunk/ldap/src:
main/antlr/distinguishedName.g
test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
Author: seelmann
Date: Mon Nov 23 20:57:00 2009
New Revision: 883499
URL: http://svn.apache.org/viewvc?rev=883499&view=rev
Log:
Fix for DIRSTUDIO-39 (Trailing escaped space not parsed correctly by the DN parser)
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=883499&r1=883498&r2=883499&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/antlr/distinguishedName.g (original)
+++ directory/shared/trunk/ldap/src/main/antlr/distinguishedName.g Mon Nov 23 20:57:00 2009
@@ -534,16 +534,14 @@
// trim trailing space characters manually
// don't know how to tell antlr that the last char mustn't be a space.
- int length = string.length();
- while ( length > 1 && string.charAt( length - 1 ) == ' ' && string.charAt( length - 2 ) != '\\' )
+ while ( string.length() > 0 && value.upValue.length() > 1
+ && value.upValue.charAt( value.upValue.length() - 1 ) == ' '
+ && value.upValue.charAt( value.upValue.length() - 2 ) != '\\' )
{
- string = string.substring( 0, length - 1 );
- length = string.length();
-
+ string = string.substring( 0, string.length() - 1 );
value.upValue = value.upValue.substring( 0, value.upValue.length() - 1 );
value.trailingSpaces += " ";
}
- string = string.replace("\\ ", " ");
value.normValue = string;
}
@@ -714,7 +712,7 @@
|
rangle:RANGLE { special = rangle.getText(); }
|
- space:SPACE { special = "\\" + space.getText(); }
+ space:SPACE { special = space.getText(); }
|
sharp:SHARP { special = sharp.getText(); }
|
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=883499&r1=883498&r2=883499&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 Mon Nov 23 20:57:00 2009
@@ -3436,4 +3436,38 @@
assertEquals( "cn", atav2.getUpType() );
assertEquals( "Amos Tori", atav2.getUpValue().getString() );
}
+
+
+ /**
+ * Test for DIRSHARED-39.
+ * (Trailing escaped space not parsed correctly by the DN parser(
+ */
+ @Test
+ public void testTrailingEscapedSpace() throws Exception
+ {
+ LdapDN dn1 = new LdapDN( "ou=A\\ ,ou=system" );
+ assertEquals( "ou=A\\ ,ou=system", dn1.getUpName() );
+ assertEquals( "ou=A\\ ,ou=system", dn1.getNormName() );
+ assertEquals( "ou=A\\ ", dn1.getRdn().getUpName() );
+ assertEquals( "ou=A\\ ", dn1.getRdn().getNormName() );
+
+ LdapDN dn2 = new LdapDN( "ou=A\\20,ou=system" );
+ assertEquals( "ou=A\\20,ou=system", dn2.getUpName() );
+ assertEquals( "ou=A\\ ,ou=system", dn2.getNormName() );
+ assertEquals( "ou=A\\20", dn2.getRdn().getUpName() );
+ assertEquals( "ou=A\\ ", dn2.getRdn().getNormName() );
+
+ LdapDN dn3 = new LdapDN( "ou=\\ ,ou=system" );
+ assertEquals( "ou=\\ ,ou=system", dn3.getUpName() );
+ assertEquals( "ou=\\ ,ou=system", dn3.getNormName() );
+ assertEquals( "ou=\\ ", dn3.getRdn().getUpName() );
+ assertEquals( "ou=\\ ", dn3.getRdn().getNormName() );
+
+ LdapDN dn4 = new LdapDN( "ou=\\20,ou=system" );
+ assertEquals( "ou=\\20,ou=system", dn4.getUpName() );
+ assertEquals( "ou=\\ ,ou=system", dn4.getNormName() );
+ assertEquals( "ou=\\20", dn4.getRdn().getUpName() );
+ assertEquals( "ou=\\ ", dn4.getRdn().getNormName() );
+ }
+
}