fixed issues found by go-fuzz
This commit is contained in:
parent
1674abae73
commit
15d372ac55
3 changed files with 37 additions and 9 deletions
18
filter.go
18
filter.go
|
|
@ -102,6 +102,9 @@ func NewQuery(s string, l Logic) (q *Query, err error) {
|
|||
switch s[2] {
|
||||
case asc, desc:
|
||||
q.s.fields = strings.Split(s[1], ".")
|
||||
if err = checkFields(q.s.fields, v); err != nil {
|
||||
return
|
||||
}
|
||||
if len(q.s.fields) > 0 {
|
||||
if s[2] == desc {
|
||||
q.s.desc = true
|
||||
|
|
@ -129,8 +132,12 @@ func NewQuery(s string, l Logic) (q *Query, err error) {
|
|||
}
|
||||
qm[m[0]] = struct{}{}
|
||||
}
|
||||
mf := strings.Split(m[0], ".")
|
||||
if err = checkFields(mf, m[0]); err != nil {
|
||||
return
|
||||
}
|
||||
q.m = append(q.m, match{
|
||||
strings.Split(m[0], "."),
|
||||
mf,
|
||||
matchFunc(m[1]),
|
||||
boolFunc(m[1]),
|
||||
})
|
||||
|
|
@ -191,9 +198,9 @@ func (q *Query) match(v reflect.Value) (ok bool) {
|
|||
if fl == 0 {
|
||||
continue
|
||||
}
|
||||
val := v.FieldByName(qv.fields[0])
|
||||
for j := 1; j < fl; j++ {
|
||||
val = val.FieldByName(qv.fields[j])
|
||||
val := walkFields(v.FieldByName(qv.fields[0]), qv.fields[1:])
|
||||
if val.Kind() == reflect.Invalid {
|
||||
continue
|
||||
}
|
||||
s, b, err := getValue(val)
|
||||
if err != nil {
|
||||
|
|
@ -239,6 +246,9 @@ func (q Query) sort(f Filter) {
|
|||
return
|
||||
}
|
||||
l := makeLess(f, q.s.fields)
|
||||
if l == nil {
|
||||
return
|
||||
}
|
||||
if q.s.desc {
|
||||
l = reverse(l)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue