Skip to content

Commit e98f885

Browse files
n10vbep
authored andcommitted
hugolib: Prevent decoding pageParam in common cases
1 parent 6498d73 commit e98f885

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

‎hugolib/page.go‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -606,15 +606,20 @@ func (p *Page) renderContent(content []byte) []byte {
606606
}
607607

608608
func (p *Page) getRenderingConfig() *helpers.Blackfriday {
609-
610609
p.renderingConfigInit.Do(func() {
611-
pageParam := cast.ToStringMap(p.GetParam("blackfriday"))
610+
p.renderingConfig = p.s.ContentSpec.NewBlackfriday()
611+
612612
if p.Language() == nil {
613613
panic(fmt.Sprintf("nil language for %s with source lang %s", p.BaseFileName(), p.lang))
614614
}
615-
p.renderingConfig = p.s.ContentSpec.NewBlackfriday()
616615

617-
if err := mapstructure.Decode(pageParam, p.renderingConfig); err != nil {
616+
bfParam := p.GetParam("blackfriday")
617+
if bfParam == nil {
618+
return
619+
}
620+
621+
pageParam := cast.ToStringMap(bfParam)
622+
if err := mapstructure.Decode(pageParam, &p.renderingConfig); err != nil {
618623
p.s.Log.FATAL.Printf("Failed to get rendering config for %s:\n%s", p.BaseFileName(), err.Error())
619624
}
620625

0 commit comments

Comments
 (0)