summaryrefslogtreecommitdiffstats
path: root/filter.go
diff options
context:
space:
mode:
authorApehaenger <joerg@ebeling.ws>2021-07-20 18:27:06 +0200
committerGitHub <noreply@github.com>2021-07-20 18:27:06 +0200
commit6ebc2104fcbfff2ae083098f7c2c08f7ae4f6679 (patch)
tree0d4b44f6a73e9369efcf6675cf8ed2079447762d /filter.go
parentFix examples (#6) (diff)
downloadldap-6ebc2104fcbfff2ae083098f7c2c08f7ae4f6679.tar
ldap-6ebc2104fcbfff2ae083098f7c2c08f7ae4f6679.tar.gz
ldap-6ebc2104fcbfff2ae083098f7c2c08f7ae4f6679.tar.bz2
ldap-6ebc2104fcbfff2ae083098f7c2c08f7ae4f6679.tar.lz
ldap-6ebc2104fcbfff2ae083098f7c2c08f7ae4f6679.tar.xz
ldap-6ebc2104fcbfff2ae083098f7c2c08f7ae4f6679.tar.zst
ldap-6ebc2104fcbfff2ae083098f7c2c08f7ae4f6679.zip
Diffstat (limited to '')
-rw-r--r--filter.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/filter.go b/filter.go
index df3c86a..9f4c949 100644
--- a/filter.go
+++ b/filter.go
@@ -7,8 +7,10 @@ package ldap
import (
"errors"
"fmt"
- "github.com/nmcclain/asn1-ber"
"strings"
+ "unicode/utf8"
+
+ ber "github.com/nmcclain/asn1-ber"
)
const (
@@ -179,10 +181,13 @@ func compileFilter(filter string, pos int) (*ber.Packet, int, error) {
default:
attribute := ""
condition := ""
- for newPos < len(filter) && filter[newPos] != ')' {
+
+ for w := 0; newPos < len(filter) && filter[newPos] != ')'; newPos += w {
+ rune, width := utf8.DecodeRuneInString(filter[newPos:])
+ w = width
switch {
case packet != nil:
- condition += fmt.Sprintf("%c", filter[newPos])
+ condition += fmt.Sprintf("%c", rune)
case filter[newPos] == '=':
packet = ber.Encode(ber.ClassContext, ber.TypeConstructed, FilterEqualityMatch, nil, FilterMap[FilterEqualityMatch])
case filter[newPos] == '>' && filter[newPos+1] == '=':
@@ -197,7 +202,6 @@ func compileFilter(filter string, pos int) (*ber.Packet, int, error) {
case packet == nil:
attribute += fmt.Sprintf("%c", filter[newPos])
}
- newPos++
}
if newPos == len(filter) {
err = NewError(ErrorFilterCompile, errors.New("ldap: unexpected end of filter"))