Skip to content

Commit

Permalink
tpl: Fix race condition in text template baseof
Browse files Browse the repository at this point in the history
Copy most of the htmltemplate cloning to the textemplate implementation
in the same function.
  • Loading branch information
moorereason authored and bep committed Jan 22, 2021
1 parent e19a046 commit 241b748
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tpl/tplimpl/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,10 +598,16 @@ func (t *templateHandler) applyBaseTemplate(overlay, base templateInfo) (tpl.Tem
}
}

templ, err = templ.Parse(overlay.template)
templ, err = texttemplate.Must(templ.Clone()).Parse(overlay.template)
if err != nil {
return nil, overlay.errWithFileContext("parse failed", err)
}

// The extra lookup is a workaround, see
// * https://github.com/golang/go/issues/16101
// * https://github.com/gohugoio/hugo/issues/2549
// templ = templ.Lookup(templ.Name())

return templ, nil
}

Expand Down

0 comments on commit 241b748

Please sign in to comment.