diff options
author | Bjørn Erik Pedersen <[email protected]> | 2021-06-29 09:38:05 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2021-06-29 09:38:05 +0200 |
commit | 49fedbc51cafa64e4eb0eae9fb79ccbe2d4c6774 (patch) | |
tree | 5162d781f340e76b0e2aa93bbf6842b515b7955e /config/defaultConfigProvider.go | |
parent | 8290720107714e98a8af60ce7888a5f75a3cdeea (diff) | |
download | hugo-49fedbc51cafa64e4eb0eae9fb79ccbe2d4c6774.tar.gz hugo-49fedbc51cafa64e4eb0eae9fb79ccbe2d4c6774.zip |
config: Fix handling of invalid OS env config overrides
Fixes #8709
Diffstat (limited to 'config/defaultConfigProvider.go')
-rw-r--r-- | config/defaultConfigProvider.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/config/defaultConfigProvider.go b/config/defaultConfigProvider.go index 80353664e..9f1c44ee1 100644 --- a/config/defaultConfigProvider.go +++ b/config/defaultConfigProvider.go @@ -169,6 +169,9 @@ func (c *defaultConfigProvider) Set(k string, v interface{}) { } key, m := c.getNestedKeyAndMap(k, true) + if m == nil { + return + } if existing, found := m[key]; found { if p1, ok := existing.(maps.Params); ok { @@ -289,6 +292,9 @@ func (c *defaultConfigProvider) Merge(k string, v interface{}) { } key, m := c.getNestedKeyAndMap(k, true) + if m == nil { + return + } if existing, found := m[key]; found { if p1, ok := existing.(maps.Params); ok { @@ -422,7 +428,12 @@ func (c *defaultConfigProvider) getNestedKeyAndMap(key string, create bool) (str return "", nil } } - current = next.(maps.Params) + var ok bool + current, ok = next.(maps.Params) + if !ok { + // E.g. a string, not a map that we can store values in. + return "", nil + } } return parts[len(parts)-1], current } |