Skip to content

Commit 4d5e3b9

Browse files
GiteaBotwxiaoguang
andauthored
Fix env config parsing for "GITEA____APP_NAME" (#26001) (#26013)
Backport #26001 by @wxiaoguang Regression of #24832 Fix the bug and add a test for it Co-authored-by: wxiaoguang <[email protected]>
1 parent 1ba0baa commit 4d5e3b9

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

modules/setting/config_env.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func decodeEnvSectionKey(encoded string) (ok bool, section, key string) {
8686
key += remaining
8787
}
8888
section = strings.ToLower(section)
89-
ok = section != "" && key != ""
89+
ok = key != ""
9090
if !ok {
9191
section = ""
9292
key = ""

modules/setting/config_env_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ func TestDecodeEnvironmentKey(t *testing.T) {
4848
assert.Equal(t, "", key)
4949
assert.False(t, file)
5050

51+
ok, section, key, file = decodeEnvironmentKey(prefix, suffix, "GITEA____KEY")
52+
assert.True(t, ok)
53+
assert.Equal(t, "", section)
54+
assert.Equal(t, "KEY", key)
55+
assert.False(t, file)
56+
5157
ok, section, key, file = decodeEnvironmentKey(prefix, suffix, "GITEA__SEC__KEY")
5258
assert.True(t, ok)
5359
assert.Equal(t, "sec", section)

0 commit comments

Comments
 (0)