From 00fe7e0408fe1571388608f358faf7dacb9cbaaf Mon Sep 17 00:00:00 2001 From: Joe Mooring Date: Thu, 17 Nov 2022 20:00:49 -0800 Subject: [PATCH] hugo/parser: Fix shortcode boolean param parsing Fixes #10451 --- parser/pageparser/item.go | 2 +- 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") }