diff options
author | Jan Cholasta <jcholast@redhat.com> | 2016-03-16 13:09:11 +0100 |
---|---|---|
committer | Jan Cholasta <jcholast@redhat.com> | 2016-06-21 09:45:20 +0200 |
commit | b484667d15932cd4a7e03a3a2c1135e7500eee4b (patch) | |
tree | 0c078c8071f4787cff95cc9ba90caad50777c580 /ipapython | |
parent | 3edf13cd8ab541908d7e2011a54e31edf1844ea2 (diff) | |
download | freeipa-b484667d15932cd4a7e03a3a2c1135e7500eee4b.tar.gz freeipa-b484667d15932cd4a7e03a3a2c1135e7500eee4b.tar.xz freeipa-b484667d15932cd4a7e03a3a2c1135e7500eee4b.zip |
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 <dkupka@redhat.com>
Reviewed-By: Pavel Vomacka <pvomacka@redhat.com>
Diffstat (limited to 'ipapython')
-rw-r--r-- | ipapython/ipaldap.py | 7 |
1 files changed, 6 insertions, 1 deletions
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: |