diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2021-07-20 18:27:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-20 18:27:43 +0200 |
commit | 7f8d1e44eeba4156c0a258b6a1af47cb0a7e2d80 (patch) | |
tree | 16215733e543353c2bd5efd1dcf89c7879e2ad3d /filter.go | |
parent | Fixed handling of UTF8 chars in filter value (#9) (diff) | |
download | ldap-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 'filter.go')
-rw-r--r-- | filter.go | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -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 } } |