fix: parser updated to support escaped quotes in search (#1704)

Co-authored-by: Palash Gupta <palashgdev@gmail.com>
This commit is contained in:
Nityananda Gohain 2022-11-10 18:24:20 +05:30 committed by GitHub
parent 9735a6e5ce
commit a3b03ef0ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -36,7 +36,7 @@ const (
DESC = "desc"
)
var tokenRegex, _ = regexp.Compile(`(?i)(and( )*?|or( )*?)?(([\w.-]+ (in|nin) \([^(]+\))|([\w.]+ (gt|lt|gte|lte) (')?[\S]+(')?)|([\w.]+ (contains|ncontains)) '[^']+')`)
var tokenRegex, _ = regexp.Compile(`(?i)(and( )*?|or( )*?)?(([\w.-]+ (in|nin) \([^(]+\))|([\w.]+ (gt|lt|gte|lte) (')?[\S]+(')?)|([\w.]+ (contains|ncontains)) [^\\]?'(.*?[^\\])')`)
var operatorRegex, _ = regexp.Compile(`(?i)(?: )(in|nin|gt|lt|gte|lte|contains|ncontains)(?: )`)
func ParseLogFilterParams(r *http.Request) (*model.LogsFilterParams, error) {

View File

@ -29,8 +29,8 @@ var correctQueriesTest = []struct {
},
{
`contains search with a different attributes`,
`resource contains 'Hello, "World"'`,
[]string{`resource ILIKE '%Hello, "World"%' `},
`resource contains 'Hello, "World" and user\'s'`,
[]string{`resource ILIKE '%Hello, "World" and user\'s%' `},
},
{
`more than one continas`,