Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asText fails when we try to print the filter #226

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 20 additions & 22 deletions ldaptor/protocols/pureldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,9 @@ class LDAPFilter_equalityMatch(LDAPAttributeValueAssertion):
def asText(self):
return (
"("
+ self.attributeDesc.value
+ self.attributeDesc.value.decode()
+ "="
+ self.escaper(self.assertionValue.value)
+ self.escaper(self.assertionValue.value.decode())
+ ")"
)

Expand All @@ -582,21 +582,21 @@ class LDAPFilter_substrings_initial(LDAPString):
tag = CLASS_CONTEXT | 0x00

def asText(self):
return self.escaper(self.value)
return self.escaper(self.value.decode())


class LDAPFilter_substrings_any(LDAPString):
tag = CLASS_CONTEXT | 0x01

def asText(self):
return self.escaper(self.value)
return self.escaper(self.value.decode())


class LDAPFilter_substrings_final(LDAPString):
tag = CLASS_CONTEXT | 0x02

def asText(self):
return self.escaper(self.value)
return self.escaper(self.value.decode())


class LDAPBERDecoderContext_Filter_substrings(BERDecoderContext):
Expand Down Expand Up @@ -673,7 +673,7 @@ def asText(self):
if final is None:
final = ""

return "(" + self.type + "=" + "*".join([initial] + any + [final]) + ")"
return "(" + self.type.decode() + "=" + "*".join([initial] + any + [final]) + ")"


class LDAPFilter_greaterOrEqual(LDAPAttributeValueAssertion):
Expand All @@ -682,9 +682,9 @@ class LDAPFilter_greaterOrEqual(LDAPAttributeValueAssertion):
def asText(self):
return (
"("
+ self.attributeDesc.value
+ self.attributeDesc.value.decode()
+ ">="
+ self.escaper(self.assertionValue.value)
+ self.escaper(self.assertionValue.value.decode())
+ ")"
)

Expand All @@ -695,9 +695,9 @@ class LDAPFilter_lessOrEqual(LDAPAttributeValueAssertion):
def asText(self):
return (
"("
+ self.attributeDesc.value
+ self.attributeDesc.value.decode()
+ "<="
+ self.escaper(self.assertionValue.value)
+ self.escaper(self.assertionValue.value.decode())
+ ")"
)

Expand All @@ -706,7 +706,7 @@ class LDAPFilter_present(LDAPAttributeDescription):
tag = CLASS_CONTEXT | 0x07

def asText(self):
return "(%s=*)" % self.value
return "(" + self.value.decode() + "=*)"


class LDAPFilter_approxMatch(LDAPAttributeValueAssertion):
Expand All @@ -715,9 +715,9 @@ class LDAPFilter_approxMatch(LDAPAttributeValueAssertion):
def asText(self):
return (
"("
+ self.attributeDesc.value
+ self.attributeDesc.value.decode()
+ "~="
+ self.escaper(self.assertionValue.value)
+ self.escaper(self.assertionValue.value.decode())
+ ")"
)

Expand Down Expand Up @@ -854,15 +854,13 @@ class LDAPFilter_extensibleMatch(LDAPMatchingRuleAssertion):
tag = CLASS_CONTEXT | 0x09

def asText(self):
return (
"("
+ (self.type.value if self.type else "")
+ (":dn" if self.dnAttributes and self.dnAttributes.value else "")
+ ((":" + self.matchingRule.value) if self.matchingRule else "")
+ ":="
+ self.escaper(self.matchValue.value)
+ ")"
)
return '(' + \
(self.type.value.decode() if self.type else '') + \
(':dn' if self.dnAttributes and self.dnAttributes.value else '') + \
((':' + self.matchingRule.value.decode()) if self.matchingRule else '') + \
':=' + \
self.escaper(self.matchValue.value.decode()) + \
')'


class LDAPBERDecoderContext_Filter(BERDecoderContext):
Expand Down
Loading