aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib
diff options
context:
space:
mode:
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/page.go4
-rw-r--r--hugolib/shortcode.go6
-rw-r--r--hugolib/shortcode_test.go32
3 files changed, 35 insertions, 7 deletions
diff --git a/hugolib/page.go b/hugolib/page.go
index 4752d11f1..37bf528c7 100644
--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -39,8 +39,6 @@ import (
"github.com/gohugoio/hugo/common/herrors"
"github.com/gohugoio/hugo/parser/metadecoders"
- "errors"
-
"github.com/gohugoio/hugo/parser/pageparser"
"github.com/gohugoio/hugo/output"
@@ -762,7 +760,7 @@ Loop:
case it.IsEOF():
break Loop
case it.IsError():
- err := fail(errors.New(it.ValStr(result.Input())), it)
+ err := fail(it.Err, it)
currShortcode.err = err
return err
diff --git a/hugolib/shortcode.go b/hugolib/shortcode.go
index 1627acacb..b2f42ff1d 100644
--- a/hugolib/shortcode.go
+++ b/hugolib/shortcode.go
@@ -497,8 +497,6 @@ func (s *shortcodeHandler) renderShortcodesForPage(p *pageState, f output.Format
return rendered, hasVariants, nil
}
-var errShortCodeIllegalState = errors.New("Illegal shortcode state")
-
func (s *shortcodeHandler) parseError(err error, input []byte, pos int) error {
if s.p != nil {
return s.p.parseError(err, input, pos)
@@ -640,7 +638,7 @@ Loop:
if params, ok := sc.params.(map[string]any); ok {
params[currItem.ValStr(source)] = pt.Next().ValTyped(source)
} else {
- return sc, errShortCodeIllegalState
+ return sc, fmt.Errorf("%s: invalid state: invalid param type %T for shortcode %q, expected a map", errorPrefix, params, sc.name)
}
}
} else {
@@ -654,7 +652,7 @@ Loop:
params = append(params, currItem.ValTyped(source))
sc.params = params
} else {
- return sc, errShortCodeIllegalState
+ return sc, fmt.Errorf("%s: invalid state: invalid param type %T for shortcode %q, expected a slice", errorPrefix, params, sc.name)
}
}
}
diff --git a/hugolib/shortcode_test.go b/hugolib/shortcode_test.go
index 3f9190962..ec521729b 100644
--- a/hugolib/shortcode_test.go
+++ b/hugolib/shortcode_test.go
@@ -1055,3 +1055,35 @@ title: "p1"
`)
}
+
+// Issue 10236.
+func TestShortcodeParamEscapedQuote(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- config.toml --
+-- content/p1.md --
+---
+title: "p1"
+---
+
+{{< figure src="/media/spf13.jpg" title="Steve \"Francia\"." >}}
+
+-- layouts/shortcodes/figure.html --
+Title: {{ .Get "title" | safeHTML }}
+-- layouts/_default/single.html --
+{{ .Content }}
+`
+
+ b := NewIntegrationTestBuilder(
+ IntegrationTestConfig{
+ T: t,
+ TxtarString: files,
+ Running: true,
+ Verbose: true,
+ },
+ ).Build()
+
+ b.AssertFileContent("public/p1/index.html", `Title: Steve "Francia".`)
+
+}