From e3ab09de3579969a4d71cc7ccd0ad3962830ff3b Mon Sep 17 00:00:00 2001 From: Carl Jackson Date: Mon, 21 Apr 2014 20:37:52 +0200 Subject: [PATCH] Remove key length sanity checking Previously, we disallowed setting the empty string as a key in a map, since at the time it seemed like doing so would allow all sorts of unsavory bugs. In practice, I think this probably isn't actually true, as I wasn't able to think of a scenario in which this bug would materialize during the several moments I thought about it. Plus, the code here to do sanity checking was wrong anyways. --- param/parse.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/param/parse.go b/param/parse.go index ae00998..7239239 100644 --- a/param/parse.go +++ b/param/parse.go @@ -72,9 +72,7 @@ func primitive(tipe, key, keytail string, values []string) { func keyed(tipe reflect.Type, key, keytail string) (string, string) { idx := strings.IndexRune(keytail, ']') - // Keys must be at least 1 rune wide: we refuse to use the empty string - // as the key - if len(keytail) < 3 || keytail[0] != '[' || idx < 2 { + if keytail[0] != '[' || idx == -1 { perr("expected a square bracket delimited index for %q "+ "(of type %v)", kpath(key, keytail), tipe) }