-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Internal Server Error when creating a repository in edge case #5772
Comments
Thanks @Larivact I can confirm this bug. |
The issue is this line: https://github.com/go-gitea/gitea/blob/master/models/repo.go#L1097 "git", "commit", fmt.Sprintf("--author='%s <%s>'", sig.Name, sig.Email), The author's name isn't being escaped - this appears to be safe despite the potential security problems due to the way the whole thing is passed as a single argument direct to the |
There are 4 other places that do the same thing in the code base. |
Thanks for tracking this down. Git does not validate email addresses but expects a name:
So the issue can also be reproduced with a Full Name that's just a space. |
Looking at what git does internally, if you set |
I guess we should do this too. If the name is effectively empty we should use the username. |
I'll have a PR up if this passes the integration tests in a few mins |
Just doing strip and trim would still let |
Take a look at my fix, it's cleverer than that. |
I see. Thanks for the quick and elegant solution. |
Fix go-gitea#5772 - Git author names are not allowed to include `\n` `<` or `>` and must not be empty. Ensure that the name passed in a signature is valid. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Ensure valid git author names passed in signatures Fix #5772 - Git author names are not allowed to include `\n` `<` or `>` and must not be empty. Ensure that the name passed in a signature is valid. * Account for pathologically named external users LDAP and the like usernames are not checked in the same way that users who signup are. Therefore just ensure that user names are also git safe and if totally pathological - Set them to "user-$UID" * Add Tests and adjust test users Make our testcases a little more pathological so that we be sure that integration tests have a chance to spot these cases. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Ensure valid git author names passed in signatures Fix go-gitea#5772 - Git author names are not allowed to include `\n` `<` or `>` and must not be empty. Ensure that the name passed in a signature is valid. * Account for pathologically named external users LDAP and the like usernames are not checked in the same way that users who signup are. Therefore just ensure that user names are also git safe and if totally pathological - Set them to "user-$UID" * Add Tests and adjust test users Make our testcases a little more pathological so that we be sure that integration tests have a chance to spot these cases. Signed-off-by: Andrew Thornton <art27@cantab.net>
I do not have Gitea installed and discovered this very weird bug at https://try.gitea.io, which currently uses af45648.
Description
<Test
(it needs to start with a less-than sign)Initialize Repository (Adds .gitignore, License and README)
(this is important it will not fail if you do not check it). ClickCreate Repository
.The text was updated successfully, but these errors were encountered: