summaryrefslogtreecommitdiffstats
path: root/filter.go
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2021-07-20 18:27:43 +0200
committerGitHub <noreply@github.com>2021-07-20 18:27:43 +0200
commit7f8d1e44eeba4156c0a258b6a1af47cb0a7e2d80 (patch)
tree16215733e543353c2bd5efd1dcf89c7879e2ad3d /filter.go
parentFixed handling of UTF8 chars in filter value (#9) (diff)
downloadldap-7f8d1e44eeba4156c0a258b6a1af47cb0a7e2d80.tar
ldap-7f8d1e44eeba4156c0a258b6a1af47cb0a7e2d80.tar.gz
ldap-7f8d1e44eeba4156c0a258b6a1af47cb0a7e2d80.tar.bz2
ldap-7f8d1e44eeba4156c0a258b6a1af47cb0a7e2d80.tar.lz
ldap-7f8d1e44eeba4156c0a258b6a1af47cb0a7e2d80.tar.xz
ldap-7f8d1e44eeba4156c0a258b6a1af47cb0a7e2d80.tar.zst
ldap-7f8d1e44eeba4156c0a258b6a1af47cb0a7e2d80.zip
Diffstat (limited to '')
-rw-r--r--filter.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/filter.go b/filter.go
index 9f4c949..05c4bb2 100644
--- a/filter.go
+++ b/filter.go
@@ -315,22 +315,23 @@ func ServerApplyFilter(f *ber.Packet, entry *Entry) (bool, LDAPResultCode) {
return false, LDAPResultOperationsError
}
attribute := f.Children[0].Value.(string)
- bytes := f.Children[1].Children[0].Data.Bytes()
- value := string(bytes[:])
+ valueBytes := f.Children[1].Children[0].Data.Bytes()
+ valueLower := strings.ToLower(string(valueBytes[:]))
for _, a := range entry.Attributes {
if strings.ToLower(a.Name) == strings.ToLower(attribute) {
for _, v := range a.Values {
+ vLower := strings.ToLower(v)
switch f.Children[1].Children[0].Tag {
case FilterSubstringsInitial:
- if strings.HasPrefix(v, value) {
+ if strings.HasPrefix(vLower, valueLower) {
return true, LDAPResultSuccess
}
case FilterSubstringsAny:
- if strings.Contains(v, value) {
+ if strings.Contains(vLower, valueLower) {
return true, LDAPResultSuccess
}
case FilterSubstringsFinal:
- if strings.HasSuffix(v, value) {
+ if strings.HasSuffix(vLower, valueLower) {
return true, LDAPResultSuccess
}
}