Skip to content

UnicodeEncodeError: SimpleLDAPObject.compare_ext doesn't call _bytesify_input on value arg #212

@jdufresne

Description

@jdufresne

Issue description:

In SimpleLDAPObject.compare_ext(), with bytes_mode=False, the arguments dn and attr are converted via ._bytesify_input(). The argument value, is not, but I believe is should be. Code is here:

if PY2:
dn = self._bytesify_input('dn', dn)
attr = self._bytesify_input('attr', attr)

Without the conversion, I receive errors that look like:

...
  File "/home/jon/devel/python-ldap/Lib/ldap/ldapobject.py", line 534, in compare_s
    return self.compare_ext_s(dn,attr,value,None,None)
  File "/home/jon/devel/python-ldap/Lib/ldap/ldapobject.py", line 519, in compare_ext_s
    msgid = self.compare_ext(dn,attr,value,serverctrls,clientctrls)
  File "/home/jon/devel/python-ldap/Lib/ldap/ldapobject.py", line 516, in compare_ext
    return self._ldap_call(self._l.compare_ext,dn,attr,value,RequestControlTuples(serverctrls),RequestControlTuples(clientctrls))
  File "/home/jon/devel/python-ldap/Lib/ldap/ldapobject.py", line 313, in _ldap_call
    result = func(*args,**kwargs)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xdf' in position 7: ordinal not in range(128)

Steps to reproduce:

  1. Use Python 2.7
  2. Initialize python-ldap with bytes_mode=False
  3. Call .compare_s() where all 3 arguments contain non-ascii characters

Operating system:

Fedora release 27

Python version:

Python 2.7

python-ldap version:

master

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy