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

vharseko
02.09.2021 dd8c650cbf1e43efbdf0c47863dafde443a6d055
FIX DN escape 'Equal sign': (#201)

https://ldapwiki.com/wiki/DN%20Escape%20Values
4 files modified
23 ■■■■■ changed files
opendj-core/src/main/java/org/forgerock/opendj/ldap/AVA.java 2 ●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/openidentityplatform/opendj/ldif/JSONEntryReader.java 9 ●●●● patch | view | raw | blame | history
opendj-core/src/test/java/org/forgerock/opendj/ldap/DNTestCase.java 10 ●●●● patch | view | raw | blame | history
opendj-rest2ldap/src/test/java/org/forgerock/opendj/rest2ldap/authz/AuthzIdTemplateTest.java 2 ●●● patch | view | raw | blame | history
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 == '\u0000')) {
                            || c == '>' || c == '\\' || c == '\u0000' || c == '=')) {
                        builder.append('\\');
                    }
                    builder.append(c);
opendj-core/src/main/java/org/openidentityplatform/opendj/ldif/JSONEntryReader.java
@@ -47,8 +47,13 @@
    public Entry readEntry() throws DecodeException, IOException {
        if (hasNext()) {
            final Map<String,List<Map<String,String>>> entry=mapper.readValue(parser,new TypeReference<Map<String,List<Map<String,String>>>>() {});
            final Entry res=new LinkedHashMapEntry(entry.keySet().iterator().next());
            for (Map<String,String> attrs : entry.get(res.getName().toString())) {
            final String key=entry.keySet().iterator().next();
            final Entry res=new LinkedHashMapEntry(key);
            List<Map<String,String>> attrsArray=entry.get(res.getName().toString());
            if (attrsArray==null) {
                attrsArray=entry.get(key);
            }
            for (Map<String,String> attrs : attrsArray) {
                for (java.util.Map.Entry<String,String> attr : attrs.entrySet()) {
                    res.addAttribute(attr.getKey(), attr.getValue());
                }
opendj-core/src/test/java/org/forgerock/opendj/ldap/DNTestCase.java
@@ -105,9 +105,9 @@
            { "givenName=John+cn=Doe,ou=People,dc=example,dc=com",
                "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",
                "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",
                "cn=Doe\\, John,ou=People,dc=example,dc=com" },
@@ -1111,14 +1111,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-rest2ldap/src/test/java/org/forgerock/opendj/rest2ldap/authz/AuthzIdTemplateTest.java
@@ -47,7 +47,7 @@
            {
                // Should perform DN quoting.
                "dn:uid={uid},ou={realm},dc=example,dc=com",
                "uid=test.user,ou=test\\+cn=quoting,dc=example,dc=com",
                "uid=test.user,ou=test\\+cn\\=quoting,dc=example,dc=com",
                map("uid", "test.user", "realm", "test+cn=quoting")
            },
            {