Browse Source

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.
Carl Jackson 12 years ago
parent
commit
e3ab09de35
1 changed files with 1 additions and 3 deletions
  1. +1
    -3
      param/parse.go

+ 1
- 3
param/parse.go View File

@ -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)
}


Loading…
Cancel
Save