Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-06-29 10:38:05 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-06-29 10:38:05 +0300
commit49fedbc51cafa64e4eb0eae9fb79ccbe2d4c6774 (patch)
tree5162d781f340e76b0e2aa93bbf6842b515b7955e /config
parent8290720107714e98a8af60ce7888a5f75a3cdeea (diff)
config: Fix handling of invalid OS env config overrides
Fixes #8709
Diffstat (limited to 'config')
-rw-r--r--config/defaultConfigProvider.go13
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
}