diff options
Diffstat (limited to 'vendor/github.com/pelletier/go-toml/keysparsing.go')
-rw-r--r-- | vendor/github.com/pelletier/go-toml/keysparsing.go | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/vendor/github.com/pelletier/go-toml/keysparsing.go b/vendor/github.com/pelletier/go-toml/keysparsing.go index 4deed81..b67664f 100644 --- a/vendor/github.com/pelletier/go-toml/keysparsing.go +++ b/vendor/github.com/pelletier/go-toml/keysparsing.go @@ -12,6 +12,7 @@ func parseKey(key string) ([]string, error) { groups := []string{} var buffer bytes.Buffer inQuotes := false + wasInQuotes := false escapeNext := false ignoreSpace := true expectDot := false @@ -33,16 +34,27 @@ func parseKey(key string) ([]string, error) { escapeNext = true continue case '"': + if inQuotes { + groups = append(groups, buffer.String()) + buffer.Reset() + wasInQuotes = true + } inQuotes = !inQuotes expectDot = false case '.': if inQuotes { buffer.WriteRune(char) } else { - groups = append(groups, buffer.String()) - buffer.Reset() + if !wasInQuotes { + if buffer.Len() == 0 { + return nil, fmt.Errorf("empty key group") + } + groups = append(groups, buffer.String()) + buffer.Reset() + } ignoreSpace = true expectDot = false + wasInQuotes = false } case ' ': if inQuotes { |