Editing CSV after 2048 chars results in "Can't render this file because it has a wrong number of fields" error #17378

Open
opened 2021-10-20 20:35:46 +00:00 by richmahn · 0 comments
richmahn commented 2021-10-20 20:35:46 +00:00 (Migrated from github.com)

Gitea Version

35b918f574

Git Version

v1.17.2

Operating System

MacOS ARM1

How are you running Gitea?

Gitea developer, so running a build of the main branch on my local system.

Database

MySQL

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Description

If you have a CSV file with more than 2048 characters (bytes), and then edit a line past 2048 characters (bytes), you get this error (line is based on whatever line the 2048th character falls on):

Can't render this file because it has a wrong number of fields in line 30.

Screenshot:

image

URL: ce02bb6107

Yet the regular diff view shows no columns were changed, and both the parent commit and new commit render as CSV tables:

image

Actually, when you even create a CSV file with more than 2048 characters, the diff of the new file even gives you this error, because the code is only rendering/diffing the first 2048 bytes, and thus if the 2048th byte mark cuts off other fields in that row, that row, 30 in this case, is seen as having the wrong number of columns. See: 44d026d24f (both diff and CSV table)

Screenshots

image

image

### Gitea Version 35b918f574464eeca89fcf0d5f3a07a58a4b5a38 ### Git Version v1.17.2 ### Operating System MacOS ARM1 ### How are you running Gitea? Gitea developer, so running a build of the main branch on my local system. ### Database MySQL ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Description If you have a CSV file with more than 2048 characters (bytes), and then edit a line past 2048 characters (bytes), you get this error (line is based on whatever line the 2048th character falls on): ``` Can't render this file because it has a wrong number of fields in line 30. ``` Screenshot: ![image](https://user-images.githubusercontent.com/2839925/138167599-af39531a-99c0-46f2-bcc0-9c8b43d637aa.png) URL: https://try.gitea.io/richmahn/test/commit/ce02bb6107c8d7ba1b8a8d30335658a84e4c9c50 Yet the regular diff view shows no columns were changed, and both the [parent commit](https://try.gitea.io/richmahn/test/src/commit/44d026d24ff571be9de86a90015dae07e02dbc29/names.csv) and [new commit](https://try.gitea.io/richmahn/test/src/commit/ce02bb6107c8d7ba1b8a8d30335658a84e4c9c50/names.csv) render as CSV tables: ![image](https://user-images.githubusercontent.com/2839925/138167744-8d834094-d49e-4d78-8c2b-cba72cc4db08.png) Actually, when you even create a CSV file with more than 2048 characters, the diff of the new file even gives you this error, because the code is only rendering/diffing the first 2048 bytes, and thus if the 2048th byte mark cuts off other fields in that row, that row, 30 in this case, is seen as having the wrong number of columns. See: https://try.gitea.io/richmahn/test/commit/44d026d24ff571be9de86a90015dae07e02dbc29 (both diff and CSV table) ### Screenshots ![image](https://user-images.githubusercontent.com/2839925/138167599-af39531a-99c0-46f2-bcc0-9c8b43d637aa.png) ![image](https://user-images.githubusercontent.com/2839925/138167744-8d834094-d49e-4d78-8c2b-cba72cc4db08.png)
This repo is archived. You cannot comment on issues.
No Milestone
No project
No Assignees
1 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: lunny/gitea#17378
No description provided.