Skip to content

Commit 0ff0ddb

Browse files
committed
Add forward slash encoding to DefaultEncoder's encodeForLDAP and encodeForDN (v3)
According to [1] and [2], the forward slash ('/') character should be encoded for LDAP filters and distinguished names. [1] https://docs.microsoft.com/en-us/windows/win32/adsi/search-filter-syntax [2] https://social.technet.microsoft.com/wiki/contents/articles/5312.active-directory-characters-to-escape.aspx
1 parent 9084186 commit 0ff0ddb

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/test/java/org/owasp/esapi/reference/EncoderTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@ public void testEncodeForLDAP() {
535535
assertEquals("Zeros", "Hi \\00", instance.encodeForLDAP("Hi \u0000"));
536536
assertEquals("LDAP Christams Tree", "Hi \\28This\\29 = is \\2a a \\5c test # � � �", instance.encodeForLDAP("Hi (This) = is * a \\ test # � � �"));
537537
assertEquals("Hi \\28This\\29 =", instance.encodeForLDAP("Hi (This) ="));
538+
assertEquals("Forward slash for \\2fMicrosoft\\2f \\2fAD\\2f", instance.encodeForLDAP("Forward slash for /Microsoft/ /AD/"));
538539
}
539540

540541
/**
@@ -547,6 +548,7 @@ public void testEncodeForLDAPWithoutEncodingWildcards() {
547548
assertEquals("No special characters to escape", "Hi This is a test #��", instance.encodeForLDAP("Hi This is a test #��", false));
548549
assertEquals("Zeros", "Hi \\00", instance.encodeForLDAP("Hi \u0000", false));
549550
assertEquals("LDAP Christams Tree", "Hi \\28This\\29 = is * a \\5c test # � � �", instance.encodeForLDAP("Hi (This) = is * a \\ test # � � �", false));
551+
assertEquals("Forward slash for \\2fMicrosoft\\2f \\2fAD\\2f", instance.encodeForLDAP("Forward slash for /Microsoft/ /AD/"));
550552
}
551553

552554
/**
@@ -563,6 +565,7 @@ public void testEncodeForDN() {
563565
assertEquals("less than greater than", "Hello\\<\\>", instance.encodeForDN("Hello<>"));
564566
assertEquals("only 3 spaces", "\\ \\ ", instance.encodeForDN(" "));
565567
assertEquals("Christmas Tree DN", "\\ Hello\\\\ \\+ \\, \\\"World\\\" \\;\\ ", instance.encodeForDN(" Hello\\ + , \"World\" ; "));
568+
assertEquals("Forward slash for \\2fMicrosoft\\2f \\2fAD\\2f", instance.encodeForDN("Forward slash for /Microsoft/ /AD/"));
566569
}
567570

568571
/**

0 commit comments

Comments
 (0)