mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-28 14:40:43 +03:00
parser/metadecoders: Add empty /data JSON file as empty map
When fetching JSON files from the /data folder that are empty they will be added as empty map[string]any. This makes sure that no empty JSON file causes the site to crash because of a failed unmarshal. This happens because empty is not a valid JSON string. It is therefore important to check the lenght of the data before passing it to the JSON unmarshal function. Fixes #8601
This commit is contained in:
parent
ad2059878a
commit
e30d711c29
2 changed files with 2 additions and 1 deletions
|
@ -122,6 +122,7 @@ func TestUnmarshalToInterface(t *testing.T) {
|
|||
}{
|
||||
{`[ "Brecker", "Blake", "Redman" ]`, JSON, []any{"Brecker", "Blake", "Redman"}},
|
||||
{`{ "a": "b" }`, JSON, expect},
|
||||
{``, JSON, map[string]any{}},
|
||||
{`#+a: b`, ORG, expect},
|
||||
{`#+DATE: <2020-06-26 Fri>`, ORG, map[string]any{"date": "2020-06-26"}},
|
||||
{`a = "b"`, TOML, expect},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue