Skip to content

Commit

Permalink
Fix env config parsing for "GITEA____APP_NAME" (go-gitea#26001)
Browse files Browse the repository at this point in the history
Regression of go-gitea#24832 

Fix the bug and add a test for it

Co-authored-by: Giteabot <teabot@gitea.io>
  • Loading branch information
wxiaoguang and GiteaBot committed Jul 20, 2023
1 parent 1ba0baa commit 9f9d90a
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 9f9d90a

Please sign in to comment.