Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6201517

javax.naming.CompositeName and javax.naming.CompoundName handle escape character ('\') incorrectly.

    XMLWordPrintable

    Details

      Description

      2004/11/30 11:00 ###@###.### --
      There is discrepency between calls to get() and toString(). Given the following test program (also attached to this bug):

      ------------------------------------------------------------
      //import com.sun.jndi.ldap.*; // for v1.4.2 and v1.5.0
      import java.util.*;
      import javax.naming.*;
      import javax.naming.ldap.*; // for v1.5.0 only

      public class NameTest {
          public static void main(String[] argumentList) throws NamingException {
              Name cName1 = null;
              Name cName2 = null;
              Name cName3 = null;
              Name cName4 = null;
              Name lName1 = null;
              Properties properties = new Properties();
              String dn = "cn=A\\\\B, cn=testRoot";

              properties.setProperty("jndi.syntax.direction", "left_to_right");
              properties.setProperty("jndi.syntax.separator", "/");
              properties.setProperty("jndi.syntax.ignorecase", "true");
              properties.setProperty("jndi.syntax.escape", "\\");

              cName1 = new CompositeName().add(dn);
              cName2 = new CompositeName(dn);
              cName3 = new CompoundName("", properties).add(dn);
              cName4 = new CompoundName(dn, properties);
              lName1 = new LdapName(dn);

              for (int i = 0; i < cName1.size(); i++) {
                  System.out.println("cName1: " + cName1.get(i));
              }
              System.out.println("cName1: " + cName1.toString());

              for (int i = 0; i < cName2.size(); i++) {
                  System.out.println("cName2: " + cName2.get(i));
              }
              System.out.println("cName2: " + cName2.toString());

              for (int i = 0; i < cName3.size(); i++) {
                  System.out.println("cName3: " + cName3.get(i));
              }
              System.out.println("cName3: " + cName3.toString());

              for (int i = 0; i < cName4.size(); i++) {
                  System.out.println("cName4: " + cName4.get(i));
              }
              System.out.println("cName4: " + cName4.toString());

              for (int i = 0; i < lName1.size(); i++) {
                  System.out.println("lName1: " + lName1.get(i));
              }
              System.out.println("lName1: " + lName1.toString());
          }
      }
      ------------------------------------------------------------

      the results on JDK v1.4.2 and v1.5.0 are:

      1. Using com.sun.jndi.ldap.LdapName (JDK v1.4.2 and JDK v1.5.0)

      JDK v1.4.2_04 -
      cName1: cn=A\\B, cn=testRoot
      cName1: cn=A\\\B, cn=testRoot *
      cName2: cn=A\B, cn=testRoot *
      cName2: cn=A\B, cn=testRoot *
      cName3: cn=A\\B, cn=testRoot
      cName3: cn=A\\\B, cn=testRoot *
      cName4: cn=A\B, cn=testRoot *
      cName4: cn=A\B, cn=testRoot *
      lName1: cn=testRoot
      lName1: cn=A\\B
      lName1: cn=A\\B, cn=testRoot

      JDK v1.5.0_00 -
      cName1: cn=A\\B, cn=testRoot
      cName1: cn=A\\\B, cn=testRoot *
      cName2: cn=A\B, cn=testRoot *
      cName2: cn=A\B, cn=testRoot *
      cName3: cn=A\\B, cn=testRoot
      cName3: cn=A\\\B, cn=testRoot *
      cName4: cn=A\B, cn=testRoot *
      cName4: cn=A\B, cn=testRoot *
      lName1: cn=testRoot
      lName1: cn=A\\B
      lName1: cn=A\\B, cn=testRoot

      2. Using javax.naming.ldap.LdapName (JDK v1.5.0 only)

      JDK v1.5.0_00 -
      cName1: cn=A\\B, cn=testRoot
      cName1: cn=A\\\B, cn=testRoot *
      cName2: cn=A\B, cn=testRoot *
      cName2: cn=A\B, cn=testRoot *
      cName3: cn=A\\B, cn=testRoot
      cName3: cn=A\\\B, cn=testRoot *
      cName4: cn=A\B, cn=testRoot *
      cName4: cn=A\B, cn=testRoot *
      lName1: cn=testRoot
      lName1: cn=A\\B
      lName1: cn=A\\B, cn=testRoot

      The only time it can produce the correct output is when we are using "cn=A\\B, cn=testRoot" as DN.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              jhjohnst Jian Johnston (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: