diff --git a/modules/setting/config_env.go b/modules/setting/config_env.go index e23b64557..bd479253d 100644 --- a/modules/setting/config_env.go +++ b/modules/setting/config_env.go @@ -86,7 +86,7 @@ func decodeEnvSectionKey(encoded string) (ok bool, section, key string) { key += remaining } section = strings.ToLower(section) - ok = section != "" && key != "" + ok = key != "" if !ok { section = "" key = "" diff --git a/modules/setting/config_env_test.go b/modules/setting/config_env_test.go index 2c1dd2f5c..edd23a24a 100644 --- a/modules/setting/config_env_test.go +++ b/modules/setting/config_env_test.go @@ -48,6 +48,12 @@ func TestDecodeEnvironmentKey(t *testing.T) { assert.Equal(t, "", key) assert.False(t, file) + ok, section, key, file = decodeEnvironmentKey(prefix, suffix, "GITEA____KEY") + assert.True(t, ok) + assert.Equal(t, "", section) + assert.Equal(t, "KEY", key) + assert.False(t, file) + ok, section, key, file = decodeEnvironmentKey(prefix, suffix, "GITEA__SEC__KEY") assert.True(t, ok) assert.Equal(t, "sec", section)