Skip to content

Commit

Permalink
hugo/parser: Fix shortcode boolean param parsing
Browse files Browse the repository at this point in the history
Fixes #10451
  • Loading branch information
jmooring authored and bep committed Nov 18, 2022
1 parent df85cb9 commit 00fe7e0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion parser/pageparser/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -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+$`)
)
9 changes: 8 additions & 1 deletion parser/pageparser/item_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

}

0 comments on commit 00fe7e0

Please sign in to comment.