Skip to content

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

Closed
@richmahn

Description

@richmahn

Gitea Version

35b918f

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: https://try.gitea.io/richmahn/test/commit/ce02bb6107c8d7ba1b8a8d30335658a84e4c9c50

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: https://try.gitea.io/richmahn/test/commit/44d026d24ff571be9de86a90015dae07e02dbc29 (both diff and CSV table)

Screenshots

image

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions