config: Fix env split to allow = character in values
author卜木 <xqbumu@gmail.com>
Sun, 30 May 2021 18:25:37 +0000 (02:25 +0800)
committerGitHub <noreply@github.com>
Sun, 30 May 2021 18:25:37 +0000 (20:25 +0200)
Fixes #8589

config/env.go
hugolib/config_test.go

index f482cd2473361017a667a0ead111f9be44ab7b16..1e7d47216557ecac4e7e09fa39ef5fbe9d275d94 100644 (file)
@@ -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]
 }
 
index 75f5b9786a6bec2c8ccf1e7010bda6a7eb404257..9e01212c7adb2502b3a0dd0fb7ead0cfaf689823 100644 (file)
@@ -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", `<a target="_blank" />`,
        )
 
        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, `<a target="_blank" />`)
 }