From b484667d15932cd4a7e03a3a2c1135e7500eee4b Mon Sep 17 00:00:00 2001 From: Jan Cholasta Date: Wed, 16 Mar 2016 13:09:11 +0100 Subject: ldap: fix handling of binary data in search filters This fixes a UnicodeDecodeError when passing non-UTF-8 binary data to LDAPClient.make_filter() and friends. https://fedorahosted.org/freeipa/ticket/5381 Reviewed-By: David Kupka Reviewed-By: Pavel Vomacka --- ipapython/ipaldap.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'ipapython') diff --git a/ipapython/ipaldap.py b/ipapython/ipaldap.py index 410ddae2c..23405c6a8 100644 --- a/ipapython/ipaldap.py +++ b/ipapython/ipaldap.py @@ -1211,7 +1211,12 @@ class LDAPClient(object): ] return self.combine_filters(flts, rules) elif value is not None: - value = ldap.filter.escape_filter_chars(value_to_utf8(value)) + if isinstance(value, bytes): + if six.PY3: + value = value.decode('raw_unicode_escape') + else: + value = value_to_utf8(value) + value = ldap.filter.escape_filter_chars(value) if not exact: template = '%s' if leading_wildcard: -- cgit