mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-02 00:15:21 +02:00
feat: AGit push options starting with {base64}
are decoded (#8479)
- When specifying push options, tooling like [git-repo-go](https://github.com/alibaba/git-repo-go) encodes pushoption values if they contain newlines or non-ASCII characters as they cannot be easily specified via the CLI otherwise. - Recognize such base64 encoded values in the pushoptions (those that have the `{base64}` prefix), if the base64 decoding fails we return the original value. - Resolves forgejo/forgejo#8161 <!--start release-notes-assistant--> ## Release notes <!--URL:https://codeberg.org/forgejo/forgejo--> - Features - [PR](https://codeberg.org/forgejo/forgejo/pulls/8479): <!--number 8479 --><!--line 0 --><!--description QUdpdCBwdXNoIG9wdGlvbnMgc3RhcnRpbmcgd2l0aCBge2Jhc2U2NH1gIGFyZSBkZWNvZGVk-->AGit push options starting with `{base64}` are decoded<!--description--> <!--end release-notes-assistant--> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8479 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: Gusted <postmaster@gusted.xyz> Co-committed-by: Gusted <postmaster@gusted.xyz>
This commit is contained in:
parent
2c01097315
commit
049899b56b
2 changed files with 37 additions and 1 deletions
|
@ -4,6 +4,7 @@
|
|||
package pushoptions
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
|
@ -92,6 +93,23 @@ func TestParse(t *testing.T) {
|
|||
assert.False(t, options.Parse("unknown=value"))
|
||||
assert.True(t, options.Empty())
|
||||
})
|
||||
|
||||
t.Run("Base64 values", func(t *testing.T) {
|
||||
options := New()
|
||||
|
||||
description := `I contain
|
||||
a
|
||||
line`
|
||||
assert.True(t, options.Parse(fmt.Sprintf("%s={base64}%s", AgitDescription, base64.StdEncoding.EncodeToString([]byte(description)))))
|
||||
val, ok := options.GetString(AgitDescription)
|
||||
assert.True(t, ok)
|
||||
assert.Equal(t, description, val)
|
||||
|
||||
assert.True(t, options.Parse(fmt.Sprintf("%s={base64}fooled you", AgitTitle)))
|
||||
val, ok = options.GetString(AgitTitle)
|
||||
assert.True(t, ok)
|
||||
assert.Equal(t, "{base64}fooled you", val)
|
||||
})
|
||||
}
|
||||
|
||||
func TestReadEnv(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue