Fix assignment to entry in nil map - 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 6f42cfbc9b80a6e1639e3c0661f530e84590fa6a
 (DIR) parent a84beee429d3b0297b1a97b191d641154f7c2e81
 (HTM) Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
       Date:   Thu, 10 Jul 2025 16:28:36 +0200
       
       Fix assignment to entry in nil map
       
       Fixes #13853
       
       Diffstat:
         M hugolib/cascade_test.go             |      24 ++++++++++++++++++++++++
         M resources/page/page_matcher.go      |       7 +++----
         M resources/page/page_matcher_test.go |       1 +
       
       3 files changed, 28 insertions(+), 4 deletions(-)
       ---
 (DIR) diff --git a/hugolib/cascade_test.go b/hugolib/cascade_test.go
       @@ -965,3 +965,27 @@ All.
        
                b.AssertLogContains("! WARN")
        }
       +
       +func TestCascadeNilMapIssue13853(t *testing.T) {
       +        t.Parallel()
       +
       +        files := `
       +-- hugo.toml --
       +-- content/test/_index.md --
       +---
       +title: Test
       +cascade:
       +- build:
       +    list: local
       +  target:
       +    path: '{/test/**}'
       +- params:
       +    title: 'Test page'
       +  target:
       +    path: '{/test/**}'
       +---
       +`
       +
       +        // Just verify that it does not panic.
       +        _ = Test(t, files)
       +}
 (DIR) diff --git a/resources/page/page_matcher.go b/resources/page/page_matcher.go
       @@ -177,6 +177,9 @@ func mapToPageMatcherParamsConfig(m map[string]any) (PageMatcherParamsConfig, er
                if pcfg.Fields == nil {
                        pcfg.Fields = make(maps.Params)
                }
       +        if pcfg.Params == nil {
       +                pcfg.Params = make(maps.Params)
       +        }
                for k, v := range m {
                        switch strings.ToLower(k) {
                        case "_target", "target":
       @@ -186,9 +189,6 @@ func mapToPageMatcherParamsConfig(m map[string]any) (PageMatcherParamsConfig, er
                                }
                                pcfg.Target = target
                        case "params":
       -                        if pcfg.Params == nil {
       -                                pcfg.Params = make(maps.Params)
       -                        }
                                params := maps.ToStringMap(v)
                                for k, v := range params {
                                        if _, found := pcfg.Params[k]; !found {
       @@ -196,7 +196,6 @@ func mapToPageMatcherParamsConfig(m map[string]any) (PageMatcherParamsConfig, er
                                        }
                                }
                        default:
       -
                                pcfg.Fields[k] = v
                        }
                }
 (DIR) diff --git a/resources/page/page_matcher_test.go b/resources/page/page_matcher_test.go
       @@ -89,6 +89,7 @@ func TestPageMatcher(t *testing.T) {
                                return v
                        }
                        c.Assert(fn(map[string]any{"_target": map[string]any{"kind": "page"}, "foo": "bar"}), qt.DeepEquals, PageMatcherParamsConfig{
       +                        Params: maps.Params{},
                                Fields: maps.Params{
                                        "foo": "bar",
                                },