fix: invalid label/flag parsing.
This commit is contained in:
parent
4d0aee67be
commit
8930236396
2 changed files with 13 additions and 0 deletions
|
@ -21,6 +21,10 @@ func DecodeToNode(labels map[string]string, rootName string, filters ...string)
|
||||||
|
|
||||||
var parts []string
|
var parts []string
|
||||||
for _, v := range split {
|
for _, v := range split {
|
||||||
|
if v == "" {
|
||||||
|
return nil, fmt.Errorf("invalid element: %s", key)
|
||||||
|
}
|
||||||
|
|
||||||
if v[0] == '[' {
|
if v[0] == '[' {
|
||||||
return nil, fmt.Errorf("invalid leading character '[' in field name (bracket is a slice delimiter): %s", v)
|
return nil, fmt.Errorf("invalid leading character '[' in field name (bracket is a slice delimiter): %s", v)
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,15 @@ func TestDecodeToNode(t *testing.T) {
|
||||||
in: map[string]string{},
|
in: map[string]string{},
|
||||||
expected: expected{node: nil},
|
expected: expected{node: nil},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
desc: "invalid label, ending by a dot",
|
||||||
|
in: map[string]string{
|
||||||
|
"traefik.http.": "bar",
|
||||||
|
},
|
||||||
|
expected: expected{
|
||||||
|
error: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
desc: "level 1",
|
desc: "level 1",
|
||||||
in: map[string]string{
|
in: map[string]string{
|
||||||
|
|
Loading…
Add table
Reference in a new issue