Gitea Webhook - wrong FilePath #7336

Closed
opened 2025-11-02 07:23:16 -06:00 by GiteaMirror · 3 comments
Owner

Originally created by @msklenicka on GitHub (May 13, 2021).

Some time ago, i wrote on gitea forum:
https://discourse.gitea.io/t/webhook-sends-wrong-incomplete-file-path/2823/4

If we used webhook gitea feature, we discovered one “strange” behavior. When Path to modified file contains SPACE, then gitea sends incomplete path in commits.modified.
Here is JSON example:

{
“secret”: “”,
“ref”: “refs/heads/master”,
“before”: “aed0bef8b7ef905893e815ebf2a25bceaddc159d”,
“after”: “66069ec2616ce7f00a5722561cf38dd91b47112e”,
“commits”: [
{
“id”: “66069ec2616ce7f00a5722561cf38dd91b47112e”,
“message”: “Gitea Webhook test\n”,
“url”: “https://gitea.local/TEST/Core/commit/66069ec2616ce7f00a5722561cf38dd91b47112e”,
“author”: {
“name”: “msklenicka”,
“email”: “msklenicka@mymail.local”,
“username”: “msklenicka”
},
“committer”: {
“name”: “msklenicka”,
“email”: “msklenicka@mymail.local”,
“username”: “msklenicka”
},
“verification”: null,
“timestamp”: “2021-01-05T10:45:28+01:00”,
“added”: [],
“removed”: [],
“modified”: [
“Java”
]
}
]… }

This is proper filepath: Java Source/jmesa.properties

We needed to fix this behavior, so we made our own release.
This is how we fixed it:
File: gitea/modules/git/commit.go

commit go_fix

Gitea version: 1.14.1

webhook0
webhook1

Originally created by @msklenicka on GitHub (May 13, 2021). Some time ago, i wrote on gitea forum: https://discourse.gitea.io/t/webhook-sends-wrong-incomplete-file-path/2823/4 If we used webhook gitea feature, we discovered one “strange” behavior. When Path to modified file contains SPACE, then gitea sends incomplete path in **commits.modified**. **Here is JSON example:** ``` { “secret”: “”, “ref”: “refs/heads/master”, “before”: “aed0bef8b7ef905893e815ebf2a25bceaddc159d”, “after”: “66069ec2616ce7f00a5722561cf38dd91b47112e”, “commits”: [ { “id”: “66069ec2616ce7f00a5722561cf38dd91b47112e”, “message”: “Gitea Webhook test\n”, “url”: “https://gitea.local/TEST/Core/commit/66069ec2616ce7f00a5722561cf38dd91b47112e”, “author”: { “name”: “msklenicka”, “email”: “msklenicka@mymail.local”, “username”: “msklenicka” }, “committer”: { “name”: “msklenicka”, “email”: “msklenicka@mymail.local”, “username”: “msklenicka” }, “verification”: null, “timestamp”: “2021-01-05T10:45:28+01:00”, “added”: [], “removed”: [], “modified”: [ “Java” ] } ]… } ``` **This is proper filepath:** _Java Source/jmesa.properties_ We needed to fix this behavior, so we made our own release. **This is how we fixed it:** **File:** gitea/modules/git/commit.go ![commit go_fix](https://user-images.githubusercontent.com/25158847/118183191-1cd8b880-b43a-11eb-8e8f-6b0f2253cd51.png) Gitea version: 1.14.1 - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes - https://try.gitea.io/msklenicka/Webhook-test/settings/hooks/654 - ![webhook0](https://user-images.githubusercontent.com/25158847/118186210-c0779800-b43d-11eb-9ac8-47ce57236736.png) ![webhook1](https://user-images.githubusercontent.com/25158847/118186212-c1102e80-b43d-11eb-909e-a6a966bc619d.png)
GiteaMirror added the type/bug label 2025-11-02 07:23:16 -06:00
Author
Owner

@zeripath commented on GitHub (May 13, 2021):

Yes this looks like it would fix the bug - do you want to send up a PR?

@zeripath commented on GitHub (May 13, 2021): Yes this looks like it would fix the bug - do you want to send up a PR?
Author
Owner

@msklenicka commented on GitHub (May 18, 2021):

If you can handle this fix yourself through your process, I'd rather. If
you clearly require a pull request from me, I will create it.
Miloslav Sklenička

čt 13. 5. 2021 v 23:41 odesílatel zeripath @.***>
napsal:

Yes this looks like it would fix the bug - do you want to send up a PR?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/go-gitea/gitea/issues/15865#issuecomment-840851665,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AF76JPYGSCKX4HXRHWNVOJ3TNRBSPANCNFSM443HMV7A
.

@msklenicka commented on GitHub (May 18, 2021): If you can handle this fix yourself through your process, I'd rather. If you clearly require a pull request from me, I will create it. Miloslav Sklenička čt 13. 5. 2021 v 23:41 odesílatel zeripath ***@***.***> napsal: > Yes this looks like it would fix the bug - do you want to send up a PR? > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > <https://github.com/go-gitea/gitea/issues/15865#issuecomment-840851665>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AF76JPYGSCKX4HXRHWNVOJ3TNRBSPANCNFSM443HMV7A> > . >
Author
Owner

@zeripath commented on GitHub (Jun 28, 2021):

Sorry I missed this.

I think there's a bit more of a problem here and we need to use:

git log --name-status -c --pretty=format:'' --parents --no-renames -t -z -1 $COMMIT_ID

and use the same style of parsing developed in LogNameStatusRepo

@zeripath commented on GitHub (Jun 28, 2021): Sorry I missed this. I think there's a bit more of a problem here and we need to use: ``` git log --name-status -c --pretty=format:'' --parents --no-renames -t -z -1 $COMMIT_ID ``` and use the same style of parsing developed in LogNameStatusRepo
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#7336