mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-25 17:30:36 +00:00
Backport #26001 by @wxiaoguang
Regression of #24832
Fix the bug and add a test for it
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
(cherry picked from commit 4d5e3b9372
)
This commit is contained in:
parent
de7f99d339
commit
d4fa6a846a
2 changed files with 7 additions and 1 deletions
|
@ -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 = ""
|
||||
|
|
|
@ -49,6 +49,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…
Reference in a new issue