mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Matthew Swift
16.43.2016 9c2b3fa279faf4f9ad6137a66d11c7fc006d796e
OPENDJ-2776 don't escape '=' in attribute values

According to RFC 4514 the '=' character does not need escaping. In
addition, re-enabled the unit tests for DN.toString() which were
surprisingly commented out.
3 files modified
18 ■■■■ changed files
opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/AVA.java 2 ●●● patch | view | raw | blame | history
opendj-sdk/opendj-core/src/test/java/org/forgerock/opendj/ldap/DNTestCase.java 12 ●●●● patch | view | raw | blame | history
opendj-sdk/opendj-rest2ldap/src/test/java/org/forgerock/opendj/rest2ldap/AuthzIdTemplateTest.java 4 ●●●● patch | view | raw | blame | history
opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/AVA.java
@@ -167,7 +167,7 @@
                } else {
                    if ((c == ' ' && si == length - 1)
                            || (c == '"' || c == '+' || c == ',' || c == ';' || c == '<'
                            || c == '=' || c == '>' || c == '\\' || c == '\u0000')) {
                            || c == '>' || c == '\\' || c == '\u0000')) {
                        builder.append('\\');
                    }
                    builder.append(c);
opendj-sdk/opendj-core/src/test/java/org/forgerock/opendj/ldap/DNTestCase.java
@@ -93,7 +93,7 @@
                "cn=doe+givenname=john,ou=people,dc=example,dc=com",
                "givenName=John+cn=Doe,ou=People,dc=example,dc=com" },
            { "givenName=John\\+cn=Doe,ou=People,dc=example,dc=com",
                "givenname=john\\+cn\\=doe,ou=people,dc=example,dc=com",
                "givenname=john\\+cn=doe,ou=people,dc=example,dc=com",
                "givenName=John\\+cn=Doe,ou=People,dc=example,dc=com" },
            { "cn=Doe\\, John,ou=People,dc=example,dc=com",
                "cn=doe\\, john,ou=people,dc=example,dc=com",
@@ -115,7 +115,7 @@
                "cn=before after,dc=example,dc=net", "CN=Before\\0dAfter,DC=example,DC=net" },
            { "2.5.4.3=#04024869",
                // Unicode codepoints from 0000-0008 are mapped to nothing.
                "cn=hi", "2.5.4.3=\\04\\02Hi" },
                "cn=hi", "2.5.4.3=#04024869" },
            { "1.1.1=", "1.1.1=", "1.1.1=" },
            { "CN=Lu\\C4\\8Di\\C4\\87", "cn=lu\u010di\u0107", "CN=Lu\u010di\u0107" },
            { "ou=\\e5\\96\\b6\\e6\\a5\\ad\\e9\\83\\a8,o=Airius", "ou=\u55b6\u696d\u90e8,o=airius",
@@ -807,8 +807,8 @@
    @Test(dataProvider = "testDNs")
    public void testToString(final String rawDN, final String normDN, final String stringDN)
            throws Exception {
        // DN dn = DN.valueOf(rawDN);
        // assertEquals(dn.toString(), stringDN);
        DN dn = DN.valueOf(rawDN);
        assertThat(dn.toString()).isEqualTo(stringDN);
    }
    /**
@@ -1004,14 +1004,14 @@
        DN actual = DN.format("uid=%s,dc=test", "#cn=foo+sn=bar");
        DN expected = DN.valueOf("dc=test").child("uid", "#cn=foo+sn=bar");
        assertEquals(actual, expected);
        assertEquals(actual.toString(), "uid=\\#cn\\=foo\\+sn\\=bar,dc=test");
        assertEquals(actual.toString(), "uid=\\#cn=foo\\+sn=bar,dc=test");
    }
    /** Tests the {@link DN#escapeAttributeValue(Object)} method. */
    @Test
    public void testEscapeAttributeValue() {
        String actual = DN.escapeAttributeValue("#cn=foo+sn=bar");
        assertEquals(actual, "\\#cn\\=foo\\+sn\\=bar");
        assertEquals(actual, "\\#cn=foo\\+sn=bar");
    }
    /** Tests the {@link DN#toNormalizedByteString()} method. */
opendj-sdk/opendj-rest2ldap/src/test/java/org/forgerock/opendj/rest2ldap/AuthzIdTemplateTest.java
@@ -11,7 +11,7 @@
 * Header, with the fields enclosed by brackets [] replaced by your own identifying
 * information: "Portions copyright [year] [name of copyright owner]".
 *
 * Copyright 2013-2015 ForgeRock AS.
 * Copyright 2013-2016 ForgeRock AS.
 */
package org.forgerock.opendj.rest2ldap;
@@ -45,7 +45,7 @@
            {
                // Should perform DN quoting.
                "dn:uid={uid},ou={realm},dc=example,dc=com",
                "dn:uid=test.user,ou=test\\+cn\\=quoting,dc=example,dc=com",
                "dn:uid=test.user,ou=test\\+cn=quoting,dc=example,dc=com",
                map("uid", "test.user", "realm", "test+cn=quoting")
            },
            {