Browse Source

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>
tags/v1.21.0-rc0
wxiaoguang 11 months ago
parent
commit
28ecac8024
No account linked to committer's email address
2 changed files with 7 additions and 1 deletions
  1. 1
    1
      modules/setting/config_env.go
  2. 6
    0
      modules/setting/config_env_test.go

+ 1
- 1
modules/setting/config_env.go View File

@@ -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 = ""

+ 6
- 0
modules/setting/config_env_test.go View File

@@ -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)

Loading…
Cancel
Save