Commit 27dcea60 authored by Guus der Kinderen's avatar Guus der Kinderen Committed by akrherz

OF-1305: Make escaping of multibyte characters in LDAP search optional. (#767)

A new property (ldap.encodeMultibyteCharacters) is introduced that controls if multibyte characters in LDAP search queries are escaped.

Escaping of these characters started with the fix for OF-830, which appears to have caused OF-1305. Although I can't say that escaping of characters is wrong (per RFC 4515), it does cause real-world problems.

This fix defaults to not encoding again (reverting back to the behavior pre OF-830, without affecting other changes made in OF-830).
parent f2dd9586
......@@ -257,6 +257,7 @@ public class LdapManager {
JiveGlobals.migrateProperty("ldap.pagedResultsSize");
JiveGlobals.migrateProperty("ldap.clientSideSorting");
JiveGlobals.migrateProperty("ldap.ldapDebugEnabled");
JiveGlobals.migrateProperty("ldap.encodeMultibyteCharacters");
String host = properties.get("ldap.host");
if (host != null) {
......@@ -2272,11 +2273,19 @@ public class LdapManager {
// regular 1-byte UTF-8 char
result.append(String.valueOf(c));
}
else if (c >= 0x080) {
else if (c >= 0x080) {
// higher-order 2, 3 and 4-byte UTF-8 chars
byte[] utf8bytes = String.valueOf(c).getBytes(StandardCharsets.UTF_8);
for (byte b : utf8bytes) {
result.append(String.format("\\%02x", b));
if ( JiveGlobals.getBooleanProperty( "ldap.encodeMultibyteCharacters", false ) )
{
byte[] utf8bytes = String.valueOf( c ).getBytes( StandardCharsets.UTF_8 );
for ( byte b : utf8bytes )
{
result.append( String.format( "\\%02x", b ) );
}
}
else
{
result.append(String.valueOf(c));
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment