Search: Ignore escaped ":" in query parser

This commit is contained in:
Michael Mayer 2020-12-14 09:21:29 +01:00
parent 83daea69c3
commit 1321192eff
2 changed files with 3 additions and 3 deletions

View file

@ -61,7 +61,7 @@ func TestParseQueryString(t *testing.T) {
assert.Equal(t, float32(33.45343), form.Lat)
})
t.Run("valid query 2", func(t *testing.T) {
form := &PhotoSearch{Query: "chroma:200 title:\"test\" after:2018-01-15 favorite:true lng:33.45343166666667"}
form := &PhotoSearch{Query: "chroma:200 title:\"te:st\" after:2018-01-15 favorite:true lng:33.45343166666667"}
err := form.ParseQueryString()
@ -72,7 +72,7 @@ func TestParseQueryString(t *testing.T) {
}
assert.Equal(t, uint8(200), form.Chroma)
assert.Equal(t, "test", form.Title)
assert.Equal(t, "te:st", form.Title)
assert.Equal(t, time.Date(2018, 01, 15, 0, 0, 0, 0, time.UTC), form.After)
assert.Equal(t, float32(33.45343), form.Lng)
})

View file

@ -139,7 +139,7 @@ func Unserialize(f SearchForm, q string) (result error) {
isKeyValue = false
key = key[:0]
value = value[:0]
} else if char == ':' {
} else if char == ':' && !escaped {
isKeyValue = true
} else if char == '"' {
escaped = !escaped