Error when parsing an empty key
This commit is contained in:
@@ -70,6 +70,9 @@ func parseKey(key string) ([]string, error) {
|
||||
if buffer.Len() > 0 {
|
||||
groups = append(groups, buffer.String())
|
||||
}
|
||||
if len(groups) == 0 {
|
||||
return nil, fmt.Errorf("empty key")
|
||||
}
|
||||
return groups, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -42,3 +42,8 @@ func TestDottedKeyBasic(t *testing.T) {
|
||||
func TestBaseKeyPound(t *testing.T) {
|
||||
testError(t, "hello#world", "invalid bare character: #")
|
||||
}
|
||||
|
||||
func TestEmptyKey(t *testing.T) {
|
||||
testError(t, "", "empty key")
|
||||
testError(t, " ", "empty key")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user