directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1130225 - in /directory: apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/ shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/ldif/
Date Wed, 01 Jun 2011 17:03:22 GMT
Author: elecharny
Date: Wed Jun  1 17:03:22 2011
New Revision: 1130225

URL: http://svn.apache.org/viewvc?rev=1130225&view=rev
Log:
Fixed a pb in training escaped spaces in RDN (DIRSERVER-1440)

Modified:
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddingEntriesWithSpecialCharactersInRDNIT.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/ldif/LdifReader.java

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddingEntriesWithSpecialCharactersInRDNIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddingEntriesWithSpecialCharactersInRDNIT.java?rev=1130225&r1=1130224&r2=1130225&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddingEntriesWithSpecialCharactersInRDNIT.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddingEntriesWithSpecialCharactersInRDNIT.java
Wed Jun  1 17:03:22 2011
@@ -20,6 +20,7 @@
 package org.apache.directory.server.operations.add;
 
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
@@ -364,4 +365,29 @@ public class AddingEntriesWithSpecialCha
         connection.delete( dn );
         connection.close();
     }
+    
+    
+    @Test
+    public void testAddRdnWithEscapedSpaces() throws Exception 
+    {
+        LdapConnection connection = ServerIntegrationUtils.getClientApiConnection( getLdapServer()
);
+
+        Entry entry = new DefaultEntry( 
+            "cn=\\ User, ou=system",
+            "objectClass: top",
+            "objectClass: person",
+            "objectClass: organizationalPerson",
+            "objectClass: inetOrgPerson", 
+            "cn: \\ User",
+            "sn: \\ Name\\ " );
+
+        connection.add( entry );
+        
+        Entry addedEntry = connection.lookup( "cn=\\ User, ou=system" );
+        
+        assertNotNull( addedEntry );
+        
+        assertEquals( "\\ Name\\ ", addedEntry.get( "sn" ).getString() );
+        assertEquals( "\\ User", addedEntry.get( "cn" ).getString() );
+      } 
 }
\ No newline at end of file

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/ldif/LdifReader.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/ldif/LdifReader.java?rev=1130225&r1=1130224&r2=1130225&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/ldif/LdifReader.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/ldif/LdifReader.java
Wed Jun  1 17:03:22 2011
@@ -691,7 +691,36 @@ public class LdifReader implements Itera
             }
             else
             {
-                return Strings.trim(line.substring(pos + 1));
+                String value = Strings.trimLeft( line.substring( pos + 1 ) );
+                int end = value.length();
+                
+                for ( int i = value.length() - 1; i > 0; i-- )
+                {
+                    char cc = value.charAt( i );
+                    
+                    if ( cc == ' ' )
+                    {
+                        if ( value.charAt( i - 1 ) == '\\' )
+                        {
+                            // Escaped space : do nothing
+                            break;
+                        }
+                        else
+                        {
+                            end = i;
+                        }
+                    }
+                    else
+                    {
+                        break;
+                    }
+                }
+                
+                String result = null;
+                
+                result = value.substring( 0, end );
+
+                return result;
             }
         }
         else



Mime
View raw message