diff options
author | Albert Nigmatzianov <albertnigma@gmail.com> | 2017-04-06 22:29:37 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-04-22 22:40:20 +0200 |
commit | e98f885b8af27f5473a89d31d0b1f02e61e8a5ec (patch) | |
tree | f03b8a3b783ffb7ac9b277c40211cb97b6ca236c | |
parent | 6498d73c08438c55d45900e64c2c04a375f747c2 (diff) |
hugolib: Prevent decoding pageParam in common cases
-rw-r--r-- | hugolib/page.go | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/hugolib/page.go b/hugolib/page.go index c63d416a8..1e9c06af7 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -606,15 +606,20 @@ func (p *Page) renderContent(content []byte) []byte { } func (p *Page) getRenderingConfig() *helpers.Blackfriday { - p.renderingConfigInit.Do(func() { - pageParam := cast.ToStringMap(p.GetParam("blackfriday")) + p.renderingConfig = p.s.ContentSpec.NewBlackfriday() + if p.Language() == nil { panic(fmt.Sprintf("nil language for %s with source lang %s", p.BaseFileName(), p.lang)) } - p.renderingConfig = p.s.ContentSpec.NewBlackfriday() - if err := mapstructure.Decode(pageParam, p.renderingConfig); err != nil { + bfParam := p.GetParam("blackfriday") + if bfParam == nil { + return + } + + pageParam := cast.ToStringMap(bfParam) + if err := mapstructure.Decode(pageParam, &p.renderingConfig); err != nil { p.s.Log.FATAL.Printf("Failed to get rendering config for %s:\n%s", p.BaseFileName(), err.Error()) } |