harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From qi...@apache.org
Subject svn commit: r794172 - in /harmony/enhanced/classlib/trunk/modules: jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/LdapNameTest.java security/src/main/java/common/org/apache/harmony/security/x509/DNParser.java
Date Wed, 15 Jul 2009 08:04:53 GMT
Author: qiuxx
Date: Wed Jul 15 08:04:52 2009
New Revision: 794172

URL: http://svn.apache.org/viewvc?rev=794172&view=rev
Log:
Fix defect of DNParser, %,*,_ should be escaped when it is in a LdapName after '\'

Modified:
    harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/LdapNameTest.java
    harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x509/DNParser.java

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/LdapNameTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/LdapNameTest.java?rev=794172&r1=794171&r2=794172&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/LdapNameTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/LdapNameTest.java
Wed Jul 15 08:04:52 2009
@@ -782,6 +782,99 @@
     
     /**
      * <p>
+     * Test method for 'javax.naming.ldap.LdapName(String)'
+     * </p>
+     * <p>
+     * Here we are testing the constructor, this method should accept a
+     * String notice here that here that we are testing the special case
+     * in which the name contains \\*, \\%, \\_
+     * </p>
+     * <p>
+     * The expected result is an instance of the class.
+     * </p>
+     */
+    public void testLdapNameString055() throws Exception {
+        LdapName ldapName;
+        String stringName;
+        String expectedName;
+        String expectedRndName;
+        List<Rdn> rdns;
+        
+        // Test \\*
+        stringName = "dc=\\*";
+        expectedName = "dc=\\*";
+        expectedRndName = "dc=*";
+        ldapName = new LdapName(stringName);
+        assertEquals(expectedName, ldapName.toString());
+        rdns = ldapName.getRdns();
+        assertEquals(expectedRndName, rdns.get(0).toString());
+        
+        stringName = "dc=\"\\*\"";
+        expectedName = "dc=\"\\*\"";
+        expectedRndName = "dc=*";
+        ldapName = new LdapName(stringName);
+        assertEquals(expectedName, ldapName.toString());
+        rdns = ldapName.getRdns();
+        assertEquals(expectedRndName, rdns.get(0).toString());
+        
+        stringName = "dc=\\\\*";
+        expectedName = "dc=\\\\*";
+        ldapName = new LdapName(stringName);
+        assertEquals(expectedName, ldapName.toString());
+        rdns = ldapName.getRdns();
+        assertEquals(expectedName, rdns.get(0).toString());
+        
+        // Test \\%
+        stringName = "dc=\\%";
+        expectedName = "dc=\\%";
+        expectedRndName = "dc=%";       
+        ldapName = new LdapName(stringName);
+        assertEquals(expectedName, ldapName.toString());
+        rdns = ldapName.getRdns();
+        assertEquals(expectedRndName, rdns.get(0).toString());
+        
+        stringName = "dc=\"\\%\"";
+        expectedName = "dc=\"\\%\"";
+        expectedRndName = "dc=%";
+        ldapName = new LdapName(stringName);
+        assertEquals(expectedName, ldapName.toString());
+        rdns = ldapName.getRdns();
+        assertEquals(expectedRndName, rdns.get(0).toString());
+        
+        stringName = "dc=\\\\%";
+        expectedName = "dc=\\\\%";
+        ldapName = new LdapName(stringName);
+        assertEquals(expectedName, ldapName.toString());
+        rdns = ldapName.getRdns();
+        assertEquals(expectedName, rdns.get(0).toString());
+        
+        // Test \\_
+        stringName = "dc=\\_";
+        expectedName = "dc=\\_";
+        expectedRndName = "dc=_";       
+        ldapName = new LdapName(stringName);
+        assertEquals(expectedName, ldapName.toString());
+        rdns = ldapName.getRdns();
+        assertEquals(expectedRndName, rdns.get(0).toString());
+        
+        stringName = "dc=\"\\_\"";
+        expectedName = "dc=\"\\_\"";
+        expectedRndName = "dc=_";
+        ldapName = new LdapName(stringName);
+        assertEquals(expectedName, ldapName.toString());
+        rdns = ldapName.getRdns();
+        assertEquals(expectedRndName, rdns.get(0).toString());
+        
+        stringName = "dc=\\\\_";
+        expectedName = "dc=\\\\_";
+        ldapName = new LdapName(stringName);
+        assertEquals(expectedName, ldapName.toString());
+        rdns = ldapName.getRdns();
+        assertEquals(expectedName, rdns.get(0).toString());
+    }
+    
+    /**
+     * <p>
      * Test method for 'javax.naming.ldap.LdapName.LdapName(List<Rdn>)'
      * </p>
      * <p>

Modified: harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x509/DNParser.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x509/DNParser.java?rev=794172&r1=794171&r2=794172&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x509/DNParser.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x509/DNParser.java
Wed Jul 15 08:04:52 2009
@@ -293,6 +293,9 @@
         case '#':
         case ';':
         case ' ':
+        case '*':
+        case '%':
+        case '_':
             //FIXME: escaping is allowed only for leading or trailing space char 
             return chars[pos];
         default:



Mime
View raw message