-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Error creating pull requests or diffs with very long diffs containing very long lines #13602
Comments
So we should add some new unit tests for git diff. |
Also affects 1.13.rc2 |
Whats a working example of this? I don't seem to be able to recreate it with the description"create a file containing a "//" If anybody could post one or link to a current example of a 500 on PR at try.gitea.io |
Here is an example: does not contain // though, but shows the same behaviour (it is reworked from a file that showed this error). seems files have to be large and have to contain long lines for this to happen |
The file contains random chars, so feel free to reuse for tests if needed. |
Thanks for example that helps: This happens in this case because: gitea/services/gitdiff/gitdiff.go Lines 743 to 749 in 24b3b21
Once the current file number is above the maxLines value, it does a continue for some reason. this means it never hits this check below the switch: gitea/services/gitdiff/gitdiff.go Lines 782 to 792 in 24b3b21
So esentially anytime you have a line which is longer than 4096 char (which will make isFragment true) and curFileLinesCount >= maxLines you will hit this error Its going to read the first part of the line that starts with gitea/services/gitdiff/gitdiff.go Lines 775 to 778 in 24b3b21
Because lineBytes[0] is just going to be whatever value was next in the large line. I'm not sure why it is like this, @zeripath should know hopefully |
It's simply a bug - I've failed to munch the end of the fragment when there is a maxLinesCount because I've just forgotten to do it. |
The code for parsing diff hunks has a bug whereby a very long line in a very long diff would not be completely read leading to an unexpected character. This PR ensures that the line is completely cleared Fix go-gitea#13602 Signed-off-by: Andrew Thornton <[email protected]>
The code for parsing diff hunks has a bug whereby a very long line in a very long diff would not be completely read leading to an unexpected character. This PR ensures that the line is completely cleared * Also allow git max line length <4096 * Add test case Fix go-gitea#13602 Signed-off-by: Andrew Thornton <[email protected]>
The code for parsing diff hunks has a bug whereby a very long line in a very long diff would not be completely read leading to an unexpected character. This PR ensures that the line is completely cleared * Also allow git max line length <4096 * Add test case Fix go-gitea#13602 Signed-off-by: Andrew Thornton <[email protected]>
* Handle incomplete diff files properly The code for parsing diff hunks has a bug whereby a very long line in a very long diff would not be completely read leading to an unexpected character. This PR ensures that the line is completely cleared Fix #13602 Signed-off-by: Andrew Thornton <[email protected]> * Also allow git max line length <4096 Signed-off-by: Andrew Thornton <[email protected]> * Add test case Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: techknowlogick <[email protected]>
The code for parsing diff hunks has a bug whereby a very long line in a very long diff would not be completely read leading to an unexpected character. This PR ensures that the line is completely cleared * Also allow git max line length <4096 * Add test case Fix #13602 Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: Andrew Thornton <[email protected]>
The code for parsing diff hunks has a bug whereby a very long line in a very long diff would not be completely read leading to an unexpected character. This PR ensures that the line is completely cleared * Also allow git max line length <4096 * Add test case Fix #13602 Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: Andrew Thornton <[email protected]>
[x]
):2020/11/17 10:12:48 ...ters/repo/compare.go:449:PrepareCompareDiff() [E] GetDiffRange: ParsePatch: Unexpected line in hunk: <line containing /// characters>
Description
When creating a PR with a file containing a "//" this will cause a 500 error page. Issue was introduced with #13157 (see services/gitdiff/gitdiff.go line 671).
Suggested solution: Even if this is considered not valid, it should only affect the specific file (For example with a text "Gitea can't generate a diff for this file"). It should not cause a 500 error page making it impossible to create PR.
This is similar to #13597 but seem to be related to LFS, so I decided to create a new issue.
The text was updated successfully, but these errors were encountered: