Skip to content

Commit

Permalink
Merge pull request #125 from cannatag/master
Browse files Browse the repository at this point in the history
escape_filter_chars
  • Loading branch information
cannatag committed Nov 14, 2015
2 parents 4babb05 + 48bee99 commit b43e4ea
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ldap3/utils/conv.py
Expand Up @@ -31,6 +31,15 @@
from ..core.exceptions import LDAPDefinitionError


def escape_filter_chars(text):
""" Escape chars mentioned in RFC4515. """
output = text.replace('\\', r'\5c')
output = output.replace(r'*', r'\2a')
output = output.replace(r'(', r'\28')
output = output.replace(r')', r'\29')
output = output.replace('\x00', r'\00')
return output

def escape_bytes(bytes_value):
if bytes_value:
if str != bytes: # Python 3
Expand Down

0 comments on commit b43e4ea

Please sign in to comment.