Ensure matcher values are present when parsing matchers from strings
Fixes #2936 Signed-off-by: gotjosh <josue.abreu@gmail.com>
This commit is contained in:
parent
0a9a48d60f
commit
05f073f42f
|
@ -120,8 +120,12 @@ func ParseMatcher(s string) (_ *Matcher, err error) {
|
||||||
return nil, errors.Errorf("bad matcher format: %s", s)
|
return nil, errors.Errorf("bad matcher format: %s", s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rawValue := ms[3]
|
||||||
|
if len(rawValue) == 0 {
|
||||||
|
return nil, errors.Errorf("matcher value is not present: %s", s)
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
rawValue = ms[3]
|
|
||||||
value strings.Builder
|
value strings.Builder
|
||||||
escaped bool
|
escaped bool
|
||||||
expectTrailingQuote bool
|
expectTrailingQuote bool
|
||||||
|
|
|
@ -189,6 +189,10 @@ func TestMatchers(t *testing.T) {
|
||||||
return append(ms, m, m2)
|
return append(ms, m, m2)
|
||||||
}(),
|
}(),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
input: `job=`,
|
||||||
|
err: `matcher value is not present: job=`,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
input: `job="value`,
|
input: `job="value`,
|
||||||
err: `matcher value contains unescaped double quote: "value`,
|
err: `matcher value contains unescaped double quote: "value`,
|
||||||
|
|
Loading…
Reference in New Issue