hugo/parser: Fix shortcode boolean param parsing - hugo - [fork] hugo port for 9front
(HTM) git clone git@git.drkhsh.at/hugo.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Submodules
(DIR) README
(DIR) LICENSE
---
(DIR) commit 00fe7e0408fe1571388608f358faf7dacb9cbaaf
(DIR) parent df85cb9ae201a892cf53e6bfebdd5f0fe0fde9bd
(HTM) Author: Joe Mooring <joe.mooring@veriphor.com>
Date: Thu, 17 Nov 2022 20:00:49 -0800
hugo/parser: Fix shortcode boolean param parsing
Fixes #10451
Diffstat:
M parser/pageparser/item.go | 2 +-
M parser/pageparser/item_test.go | 9 ++++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
---
(DIR) diff --git 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+$`)
)
(DIR) diff --git 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")
}