You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm getting a reproductible 500 error when Gitea tries to show and parses a certain type of commit.
The process I found to reproduce this error is this one:
Inside a branch of a repository, clic on "New file";
Name the file with Windows-style backslash (exemple : "testing\test.test"), and put some content in it. The file now exists in the repo, but not in a folder, as per the backslash;
In a new commit, rename the file by replacing the backslash by a slash. In my setup, "testing\test.test" becomes "testing/test.test". Gitea now display the folder, and the file in it;
I traced back the error to this part of code in my version of Gitea, in the file "services\gitdiff\gitdiff.go" :
// Note: In case file name is surrounded by double quotes (it happens only in git-shell).
// e.g. diff --git "a/xxx" "b/xxx"
hasQuote := line[len(cmdDiffHead)] == '"'
if hasQuote {
middle = strings.Index(line, ` "b/`)
} else {
middle = strings.Index(line, " b/")
}
beg := len(cmdDiffHead)
a := line[beg+2 : middle] <== line bringing out the error
b := line[middle+3:]
From what I understand of the code involved in the error, it seems there is a problem when a diff file contains multiples "types" of "diff --git " lines (with and without doubles quotes), as the git diff of the commit replacing the backslash by a slash which brings out the error contains both :
a 'diff --git a/testing/test.test b/testing/test.test' line
a 'diff --git "a/testing\\test.test" "b/testing\\test.test"' line
Side note : After this bug occurs, pull requests doesn't works anymore on my gitea for the repository containing the commit, between the dev branch (containing the offending commit) and the master branch. I have not been able to reproduce it on try.gitea.io, but I guess it is a side effect ?
The text was updated successfully, but these errors were encountered:
zeripath
added a commit
to zeripath/gitea
that referenced
this issue
Aug 21, 2020
services/gitdiff/gitdiff.go whereby there it assumed that the path would
always be quoted on both sides
This PR simplifies the code here and uses fmt.Fscanf to parse the
strings as necessary.
Fixgo-gitea#12546
Signed-off-by: Andrew Thornton <[email protected]>
* Fix diff path unquoting
services/gitdiff/gitdiff.go whereby there it assumed that the path would
always be quoted on both sides
This PR simplifies the code here and uses fmt.Fscanf to parse the
strings as necessary.
Fix#12546
Signed-off-by: Andrew Thornton <[email protected]>
* Add testcase as per @mrsdizzie
Signed-off-by: Andrew Thornton <[email protected]>
zeripath
added a commit
to zeripath/gitea
that referenced
this issue
Aug 23, 2020
Backport go-gitea#12554
* Fix diff path unquoting
services/gitdiff/gitdiff.go whereby there it assumed that the path would
always be quoted on both sides
This PR simplifies the code here and uses fmt.Fscanf to parse the
strings as necessary.
Fixgo-gitea#12546
Signed-off-by: Andrew Thornton <[email protected]>
* Add testcase as per @mrsdizzie
Signed-off-by: Andrew Thornton <[email protected]>
Backport #12554
* Fix diff path unquoting
services/gitdiff/gitdiff.go whereby there it assumed that the path would
always be quoted on both sides
This PR simplifies the code here and uses fmt.Fscanf to parse the
strings as necessary.
Fix#12546
Signed-off-by: Andrew Thornton <[email protected]>
* Add testcase as per @mrsdizzie
Signed-off-by: Andrew Thornton <[email protected]>
[x]
):Description
I'm getting a reproductible 500 error when Gitea tries to show and parses a certain type of commit.
The process I found to reproduce this error is this one:
I traced back the error to this part of code in my version of Gitea, in the file "services\gitdiff\gitdiff.go" :
From what I understand of the code involved in the error, it seems there is a problem when a diff file contains multiples "types" of "diff --git " lines (with and without doubles quotes), as the git diff of the commit replacing the backslash by a slash which brings out the error contains both :
Side note : After this bug occurs, pull requests doesn't works anymore on my gitea for the repository containing the commit, between the dev branch (containing the offending commit) and the master branch. I have not been able to reproduce it on try.gitea.io, but I guess it is a side effect ?
The text was updated successfully, but these errors were encountered: