Skip to content

Commit

Permalink
Fix env config parsing for "GITEA____APP_NAME" (#26001) (#26013)
Browse files Browse the repository at this point in the history
Backport #26001 by @wxiaoguang

Regression of #24832 

Fix the bug and add a test for it

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
  • Loading branch information
GiteaBot and wxiaoguang committed Jul 20, 2023
1 parent 1ba0baa commit 4d5e3b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/setting/config_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down
6 changes: 6 additions & 0 deletions modules/setting/config_env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4d5e3b9

Please sign in to comment.