diff options
author | Joe Mooring <[email protected]> | 2022-11-17 20:00:49 -0800 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2022-11-18 09:34:10 +0100 |
commit | 00fe7e0408fe1571388608f358faf7dacb9cbaaf (patch) | |
tree | 12cc9e31ca6cbc440ec3e61e7b3075b5247643ac /parser | |
parent | df85cb9ae201a892cf53e6bfebdd5f0fe0fde9bd (diff) | |
download | hugo-00fe7e0408fe1571388608f358faf7dacb9cbaaf.tar.gz hugo-00fe7e0408fe1571388608f358faf7dacb9cbaaf.zip |
hugo/parser: Fix shortcode boolean param parsing
Fixes #10451
Diffstat (limited to 'parser')
-rw-r--r-- | parser/pageparser/item.go | 2 | ||||
-rw-r--r-- | parser/pageparser/item_test.go | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/parser/pageparser/item.go b/parser/pageparser/item.go index 2083be70a..d4dcc2785 100644 --- a/parser/pageparser/item.go +++ b/parser/pageparser/item.go @@ -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+$`) ) diff --git a/parser/pageparser/item_test.go b/parser/pageparser/item_test.go index db4cc127a..72bb69103 100644 --- a/parser/pageparser/item_test.go +++ b/parser/pageparser/item_test.go @@ -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") } |