Skip to content

Commit

Permalink
Remove key length sanity checking
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zenazn committed Apr 21, 2014
1 parent f8ba05d commit e3ab09d
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions param/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit e3ab09d

Please sign in to comment.