Tags with % cause an error #3045

Closed
opened 2025-11-02 04:58:48 -06:00 by GiteaMirror · 6 comments
Owner

Originally created by @jeblair on GitHub (Mar 13, 2019).

  • Gitea version (or commit ref): 91775c1 (latest on try.gitea.io)
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant

Description

Git supports "%" in ref names, but Gitea rejects them. In the web UI, creating a tag with the name "debian/1%1.6.0-2" produces the error "TagName must be a well-formed Git reference name." When attempting to push the same tag to a repo, the following error appears:

2019/03/13 18:20:55 [...io/gitea/cmd/hook.go:109 runHookPreReceive()] [F] retrieve protected branches information failed: parse https://localhost:3000/api/internal/branch/620/refs/tags/debian/1%!.(MISSING)0-2: invalid URL escape "%!"(MISSING)

We can confirm that git supports a ref with "%" by either creating a tag with git or running:

git check-ref-format "debian/1%1.6.0-2"

Screenshots

https://screenshots.firefox.com/u1vElZ2A4wLQeXIk/try.gitea.io

Originally created by @jeblair on GitHub (Mar 13, 2019). - Gitea version (or commit ref): 91775c1 (latest on try.gitea.io) - Can you reproduce the bug at https://try.gitea.io: - [X] Yes (provide example URL) - [ ] No - [ ] Not relevant ## Description Git supports "%" in ref names, but Gitea rejects them. In the web UI, creating a tag with the name "debian/1%1.6.0-2" produces the error "TagName must be a well-formed Git reference name." When attempting to push the same tag to a repo, the following error appears: ``` 2019/03/13 18:20:55 [...io/gitea/cmd/hook.go:109 runHookPreReceive()] [F] retrieve protected branches information failed: parse https://localhost:3000/api/internal/branch/620/refs/tags/debian/1%!.(MISSING)0-2: invalid URL escape "%!"(MISSING) ``` We can confirm that git supports a ref with "%" by either creating a tag with git or running: ``` git check-ref-format "debian/1%1.6.0-2" ``` ## Screenshots https://screenshots.firefox.com/u1vElZ2A4wLQeXIk/try.gitea.io
GiteaMirror added the type/enhancement label 2025-11-02 04:58:48 -06:00
Author
Owner

@zeripath commented on GitHub (Mar 15, 2019):

Paging @mrsdizzie - this is another example of bad escaping.

@zeripath commented on GitHub (Mar 15, 2019): Paging @mrsdizzie - this is another example of bad escaping.
Author
Owner

@mrsdizzie commented on GitHub (Mar 26, 2019):

This would have at least two separate causes. Not being able to add via the Web interface is because of bad logic here: 22d3d029e6/modules/validation/binding.go (L21-L22)

On the command line, I was able to successfully push a tag with the same name as the example above:

https://try.gitea.io/mrsdizzie/parsing-errors/releases

Are you able to replicate not being able to push tags on the command line with try.gitea.org? If so, can you let me know the exact commands for creating and pushing since I wasn't able to reproduce that part just using the name above. I'll start working on a PR for the other part (and this should get a bug tag)

@mrsdizzie commented on GitHub (Mar 26, 2019): This would have at least two separate causes. Not being able to add via the Web interface is because of bad logic here: https://github.com/go-gitea/gitea/blob/22d3d029e6f7e6359f3a6fbe8b7827b579ac7445/modules/validation/binding.go#L21-L22 On the command line, I was able to successfully push a tag with the same name as the example above: https://try.gitea.io/mrsdizzie/parsing-errors/releases Are you able to replicate not being able to push tags on the command line with try.gitea.org? If so, can you let me know the exact commands for creating and pushing since I wasn't able to reproduce that part just using the name above. I'll start working on a PR for the other part (and this should get a bug tag)
Author
Owner

@jeblair commented on GitHub (Mar 26, 2019):

I agree, pushing the branch does work in try.gitea.io. Moreover, I've
also verified that it works locally using gitea master. I re-confirmed
that it did not work in 1.7.4, and a little digging suggests that
@zeripath fixed that in #6304 two days before I reported the bug.

Perhaps I was sloppy in testing. I'm sorry for the confusion.

At any rate, it looks like that half of the problem is solved and the
only issue remaining is the web validation.

Thanks!

@jeblair commented on GitHub (Mar 26, 2019): I agree, pushing the branch does work in try.gitea.io. Moreover, I've also verified that it works locally using gitea master. I re-confirmed that it did not work in 1.7.4, and a little digging suggests that @zeripath fixed that in #6304 two days before I reported the bug. Perhaps I was sloppy in testing. I'm sorry for the confusion. At any rate, it looks like that half of the problem is solved and the only issue remaining is the web validation. Thanks!
Author
Owner

@mrsdizzie commented on GitHub (Mar 26, 2019):

Ah OK great, glad that also works for you. The PR I just made will fix the web validation side pending review/approval.

@mrsdizzie commented on GitHub (Mar 26, 2019): Ah OK great, glad that also works for you. The PR I just made will fix the web validation side pending review/approval.
Author
Owner

@mrsdizzie commented on GitHub (Mar 26, 2019):

This can be closed per d056bf3

@mrsdizzie commented on GitHub (Mar 26, 2019): This can be closed per d056bf3
Author
Owner

@zeripath commented on GitHub (Mar 26, 2019):

Fixed by #6437 and #6304

@zeripath commented on GitHub (Mar 26, 2019): Fixed by #6437 and #6304
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#3045