diff options
author | Jason Song <i@wolfogre.com> | 2023-05-16 14:49:40 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-16 14:49:40 +0800 |
commit | d81659d03947ac4533099089c5f442437e1d6887 (patch) | |
tree | 2bf4ac98a99406d986c87e2032456c21c8d48491 /models | |
parent | 30d922226778a469f01bbb1b933e65428f9266df (diff) | |
download | gitea-d81659d03947ac4533099089c5f442437e1d6887.tar.gz gitea-d81659d03947ac4533099089c5f442437e1d6887.zip |
Respect original content when creating secrets (#24745)
Fix #24721.
Follow what GitHub does:
- Don't trim spaces for secrets.
- Newline should be `\n` instead of `\r\n`.
Did some tests with:
```yaml
name: secrets
on: push
jobs:
show_secrets:
runs-on: ubuntu-latest
steps:
- name: Dump secrets context
run: echo '${{ toJSON(secrets) }}' | base64
```
`AAAAAA`:
```text
AAAAAA
AAAAAA
```
`BBBBBB`:
```text
BBBBBB
BBBBBB
```
On GitHub:
<img width="675" alt="image"
src="https://github.com/go-gitea/gitea/assets/9418365/0ec60652-c2a3-47bb-9f9d-7e81665355a8">
On Gitea (before):
<img width="673" alt="image"
src="https://github.com/go-gitea/gitea/assets/9418365/cce818bf-5edc-4656-86e1-2c81c304cdb2">
On Gitea (after):
<img width="673" alt="image"
src="https://github.com/go-gitea/gitea/assets/9418365/0b3b15af-4d48-4bab-a334-4738a1b0eb4a">
Diffstat (limited to 'models')
-rw-r--r-- | models/secret/secret.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/models/secret/secret.go b/models/secret/secret.go index f970d5319e..8b23b6c35c 100644 --- a/models/secret/secret.go +++ b/models/secret/secret.go @@ -59,7 +59,7 @@ func newSecret(ownerID, repoID int64, name, data string) *Secret { // InsertEncryptedSecret Creates, encrypts, and validates a new secret with yet unencrypted data and insert into database func InsertEncryptedSecret(ctx context.Context, ownerID, repoID int64, name, data string) (*Secret, error) { - encrypted, err := secret_module.EncryptSecret(setting.SecretKey, strings.TrimSpace(data)) + encrypted, err := secret_module.EncryptSecret(setting.SecretKey, data) if err != nil { return nil, err } |