From ee733085b7f5d3f2aef1667901ab6ecb8041d699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E6=9C=A8?= Date: Mon, 31 May 2021 02:25:37 +0800 Subject: [PATCH] config: Fix env split to allow = character in values Fixes #8589 --- config/env.go | 2 +- hugolib/config_test.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/config/env.go b/config/env.go index f482cd247..1e7d47216 100644 --- a/config/env.go +++ b/config/env.go @@ -41,7 +41,7 @@ func SetEnvVars(oldVars *[]string, keyValues ...string) { } func SplitEnvVar(v string) (string, string) { - parts := strings.Split(v, "=") + parts := strings.SplitN(v, "=", 2) return parts[0], parts[1] } diff --git a/hugolib/config_test.go b/hugolib/config_test.go index 75f5b9786..9e01212c7 100644 --- a/hugolib/config_test.go +++ b/hugolib/config_test.go @@ -528,6 +528,8 @@ theme_param="themevalue2" // Issue #8346 "HUGOxPARAMSxMYTHEME_SECTIONxTHEME_PARAM", "themevalue_changed", "HUGOxPARAMSxMYTHEME_SECTION2xTHEME_PARAM", "themevalue2_changed", + "HUGO_PARAMS_EMPTY", ``, + "HUGO_PARAMS_HTML", ``, ) b.Build(BuildCfg{}) @@ -547,4 +549,6 @@ theme_param="themevalue2" c.Assert(cfg.Get("params.api_config.another_key"), qt.Equals, "default another_key") c.Assert(cfg.Get("params.mytheme_section.theme_param"), qt.Equals, "themevalue_changed") c.Assert(cfg.Get("params.mytheme_section2.theme_param"), qt.Equals, "themevalue2_changed") + c.Assert(cfg.Get("params.empty"), qt.Equals, ``) + c.Assert(cfg.Get("params.html"), qt.Equals, ``) }