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
Contributor

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

Activity

richmahn

richmahn commented on Oct 20, 2021

@richmahn
ContributorAuthor

Ok, found it has to do with this setting here to read 4096 bytes from a blob:

https://github.com/go-gitea/gitea/blob/35b918f/modules/git/blob_nogogit.go#L57

zeripath

zeripath commented on Oct 20, 2021

@zeripath
Contributor

Err it shouldn't have...

There was another bug somewhere that might have resolved this though

richmahn

richmahn commented on Oct 21, 2021

@richmahn
ContributorAuthor

Oops, didn't mean to close!

added a commit that references this issue on Oct 24, 2021
44f2c27
added a commit that references this issue on Oct 25, 2021
02b5b3f
added a commit that references this issue on Oct 25, 2021
1fbdf96
added a commit that references this issue on Mar 28, 2022
0c29d91
locked and limited conversation to collaborators on Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @zeripath@richmahn@6543

      Issue actions

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