aboutsummaryrefslogtreecommitdiffstats
path: root/modules/setting
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-07-20 17:16:29 +0800
committerGitHub <noreply@github.com>2023-07-20 09:16:29 +0000
commit28ecac8024eeb17352ab5bb531850ad38772cee8 (patch)
tree448e9c84ea7d2ab89a77e7d869b6a482dd075da1 /modules/setting
parentd7a8d09da013f14bf795fa8efc3a0eac7f259d02 (diff)
downloadgitea-28ecac8024eeb17352ab5bb531850ad38772cee8.tar.gz
gitea-28ecac8024eeb17352ab5bb531850ad38772cee8.zip
Fix env config parsing for "GITEA____APP_NAME" (#26001)
Regression of #24832 Fix the bug and add a test for it Co-authored-by: Giteabot <teabot@gitea.io>
Diffstat (limited to 'modules/setting')
-rw-r--r--modules/setting/config_env.go2
-rw-r--r--modules/setting/config_env_test.go6
2 files changed, 7 insertions, 1 deletions
diff --git a/modules/setting/config_env.go b/modules/setting/config_env.go
index e23b64557f..bd479253dc 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 2c1dd2f5c7..edd23a24aa 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)