Skip to content

Commit fc0ee12

Browse files
committed
revise the comments to reflect changes to character replacement logic
1 parent 1cbabf2 commit fc0ee12

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

user_sync/connector/directory_ldap.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,10 @@ def format_ldap_query_string(query, **kwargs):
337337
escaped_args = {}
338338
# kwargs is a dict that would normally be passed to string.format
339339
for k, v in six.iteritems(kwargs):
340-
# python 2 and 3 both support string translation, which would make this process easier
341-
# unfortunately, they are not compatible, and six does not provide a wrapper.
342-
# additionally, the py2 version does not work with multi-char replacement values
343-
# here, we're walking through the format replacement string char by char and replacing
344-
# with the escape chars if needed. since strings are immutable, we build a list of chars
345-
# for the escaped string, and join it together after translating the string
340+
# LDAP special characters are escaped in the general format '\' + hex(char)
341+
# we need to run through the string char by char and if the char exists in
342+
# the escape_char list, get the ord of it (decimal ascii value), convert it to hex, and
343+
# replace the '0x' with '\'
346344
escaped_list = []
347345
for c in v:
348346
if c in escape_chars:

0 commit comments

Comments
 (0)