Skip to content

Commit

Permalink
👽 Add patched version of LDAPString to workaround TypeError on LDAP f…
Browse files Browse the repository at this point in the history
…iltering in the upstream library
  • Loading branch information
jemrobinson committed Feb 26, 2024
1 parent e522f8d commit 6d72715
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions apricot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from .__about__ import __version__, __version_info__
from .apricot_server import ApricotServer
from .patches import LDAPString # noqa: F401

__all__ = [
"__version__",
Expand Down
15 changes: 15 additions & 0 deletions apricot/patches/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""Patch LDAPString to avoid TypeError when parsing LDAP filter strings"""

from ldaptor.protocols.pureldap import LDAPString

old_init = LDAPString.__init__


def patched_init(self, *k, **kw):
"""Patch LDAPString init to store its value as 'str' not 'bytes'"""
old_init(self, *k, **kw)
if isinstance(self.value, bytes):
self.value = self.value.decode()


LDAPString.__init__ = patched_init

0 comments on commit 6d72715

Please sign in to comment.