for opt, value in self.config.get('OPTIONS', {}).items():
if isinstance(opt, str):
opt = getattr(ldap, opt)
try:
if isinstance(value, str):
value = getattr(ldap, value)
except AttributeError:
pass
in python2, the checks vs 'str' are not very robust. the caller could pass a unicode string like u"OPT_PROTOCOL_VERSION". In current code this would trigger an uncaught exception (because python-ldap only accepts integers)
(I faced this issue with a wiki - realms on github. Pretty hard to trace back to LDAP as of course the only symptom was a 500 HTTP error. In the realms wiki the parameters come from a JSON file, that's of course parsed to unicode)
hello,
in method connect():
in python2, the checks vs 'str' are not very robust. the caller could pass a unicode string like
u"OPT_PROTOCOL_VERSION"
. In current code this would trigger an uncaught exception (because python-ldap only accepts integers)(I faced this issue with a wiki - realms on github. Pretty hard to trace back to LDAP as of course the only symptom was a 500 HTTP error. In the realms wiki the parameters come from a JSON file, that's of course parsed to unicode)