]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
hugo/parser: Fix shortcode boolean param parsing
authorJoe Mooring <joe.mooring@veriphor.com>
Fri, 18 Nov 2022 04:00:49 +0000 (20:00 -0800)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Fri, 18 Nov 2022 08:34:10 +0000 (09:34 +0100)
Fixes #10451

parser/pageparser/item.go
parser/pageparser/item_test.go

index 2083be70a94139faa35afc11c73d63d0c96cc460..d4dcc2785e96ef9a4456c49b231dee58e3c7f858 100644 (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+$`)
 )
index db4cc127a823983e3d11d4e5ad89f6e9d6ce9968..72bb69103b990c70ff1ee151ddf1ad819fdfccbf 100644 (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")
 
 }