summaryrefslogtreecommitdiffstats
path: root/hugolib/shortcode.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-06-14 18:16:45 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-06-14 20:19:08 +0200
commitd6ed17c60fd13c933347110c720afa09e04df1c8 (patch)
tree799961743618190d082dc705fd032fa43429d5b9 /hugolib/shortcode.go
parent145b3fcce35fbac25c7033c91c1b7ae6d1179da8 (diff)
Fix crash for closing shortcode with no .Inner set
Fixes #6857 Closes #7330
Diffstat (limited to 'hugolib/shortcode.go')
-rw-r--r--hugolib/shortcode.go23
1 files changed, 15 insertions, 8 deletions
diff --git a/hugolib/shortcode.go b/hugolib/shortcode.go
index 0d3bfff18..f5413a932 100644
--- a/hugolib/shortcode.go
+++ b/hugolib/shortcode.go
@@ -496,19 +496,26 @@ Loop:
case currItem.IsRightShortcodeDelim():
// we trust the template on this:
// if there's no inner, we're done
- if !sc.isInline && !sc.info.ParseInfo().IsInner {
- return sc, nil
+ if !sc.isInline {
+ if sc.info == nil {
+ // This should not happen.
+ return sc, fail(errors.New("BUG: template info not set"), currItem)
+ }
+ if !sc.info.ParseInfo().IsInner {
+ return sc, nil
+ }
}
case currItem.IsShortcodeClose():
next := pt.Peek()
- if !sc.isInline && !sc.info.ParseInfo().IsInner {
- if next.IsError() {
- // return that error, more specific
- continue
+ if !sc.isInline {
+ if sc.info == nil || !sc.info.ParseInfo().IsInner {
+ if next.IsError() {
+ // return that error, more specific
+ continue
+ }
+ return sc, fail(_errors.Errorf("shortcode %q has no .Inner, yet a closing tag was provided", next.Val), next)
}
-
- return sc, fail(_errors.Errorf("shortcode %q has no .Inner, yet a closing tag was provided", next.Val), next)
}
if next.IsRightShortcodeDelim() {
// self-closing