hugo/parser: Fix shortcode boolean param parsing

Fixes #10451
This commit is contained in:
Joe Mooring authored and Bjørn Erik Pedersen committed 2022-11-18 09:34:10 +01:00
1 parent df85cb9ae2
commit 00fe7e0408
2 files changed
+9 -2

No files matched your search

+1 -1
View File
@@ -215,7 +215,7 @@ const (
)
var (
boolRe = regexp.MustCompile(`^(true$)|(false$)`)
boolRe = regexp.MustCompile(`^(true|false)$`)
intRe = regexp.MustCompile(`^[-+]?\d+$`)
floatRe = regexp.MustCompile(`^[-+]?\d*\.\d+$`)
)
+8 -1
View File
@@ -38,6 +38,13 @@ func TestItemValTyped(t *testing.T) {
c.Assert(Item{low: 0, high: len(source)}.ValTyped(source), qt.Equals, true)
source = []byte("false")
c.Assert(Item{low: 0, high: len(source)}.ValTyped(source), qt.Equals, false)
source = []byte("trued")
source = []byte("falsex")
c.Assert(Item{low: 0, high: len(source)}.ValTyped(source), qt.Equals, "falsex")
source = []byte("xfalse")
c.Assert(Item{low: 0, high: len(source)}.ValTyped(source), qt.Equals, "xfalse")
source = []byte("truex")
c.Assert(Item{low: 0, high: len(source)}.ValTyped(source), qt.Equals, "truex")
source = []byte("xtrue")
c.Assert(Item{low: 0, high: len(source)}.ValTyped(source), qt.Equals, "xtrue")
}