CSV rendering for TSV files does not show rows with empty fields #7631

Closed
opened 2025-11-02 07:31:56 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @richmahn on GitHub (Jul 27, 2021).

Originally assigned to: @richmahn on GitHub.

TSV (bad rendering): https://try.gitea.io/richmahn/test/src/branch/master/empty_fields.tsv

CSV (works): https://try.gitea.io/richmahn/test/src/branch/master/empty_fields.csv

Description

If a TSV file's row has fields that are empty (i.e. two tabs with no characters in-between), the row gets flagged by the CSV parser as not having the right number of fields:

record on line 3: wrong number of fields

For a CSV file (actual comma delimited) it is ok with empty fields.

The following raw text fails for TSV render despite having the right number of tabs (3) each row:

Row	Field1	Field2	Field3
1	a	b	c
2		d	f
3	g	h	i
4		k	l
5	m	n	
6	p	q	r
7			u
8	v	w	x
9	z		
10			

NOTE: THIS WORKED OK ON GITEA v1.14.X!

Screenshots

Missing rows:

image

Originally created by @richmahn on GitHub (Jul 27, 2021). Originally assigned to: @richmahn on GitHub. - Gitea version (or commit ref): 4b6370c46d8d75a163e271b3636e48791d4cc641 (main) - Can you reproduce the bug at https://try.gitea.io: - [x] Yes (provide example URL) - [ ] No TSV (bad rendering): https://try.gitea.io/richmahn/test/src/branch/master/empty_fields.tsv CSV (works): https://try.gitea.io/richmahn/test/src/branch/master/empty_fields.csv ## Description If a TSV file's row has fields that are empty (i.e. two tabs with no characters in-between), the row gets flagged by the CSV parser as not having the right number of fields: `record on line 3: wrong number of fields` For a CSV file (actual comma delimited) it is ok with empty fields. The following raw text fails for TSV render despite having the right number of tabs (3) each row: ``` Row Field1 Field2 Field3 1 a b c 2 d f 3 g h i 4 k l 5 m n 6 p q r 7 u 8 v w x 9 z 10 ``` *NOTE: THIS WORKED OK ON GITEA v1.14.X!* ## Screenshots Missing rows: ![image](https://user-images.githubusercontent.com/2839925/127174512-14e124be-d2b3-4558-ba7c-c98cadc6009f.png)
GiteaMirror added the type/bug label 2025-11-02 07:31:56 -06:00
Author
Owner

@richmahn commented on GitHub (Jul 27, 2021):

Found this is due to this line, which trims the tabs!

rd.TrimLeadingSpace = true

4b6370c46d/modules/csv/csv.go (L26)

@richmahn commented on GitHub (Jul 27, 2021): Found this is due to this line, which trims the tabs! ` rd.TrimLeadingSpace = true` https://github.com/go-gitea/gitea/blob/4b6370c46d8d75a163e271b3636e48791d4cc641/modules/csv/csv.go#L26
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#7631