mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-04 22:00:39 +00:00
* Fixes #16559 - Do not trim leading spaces for tab delimited * Adds back semicolon delimited test * Fixes linting * Adds nolint directive to test because uses strings starting with spaces Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
parent
6e2c64f27a
commit
8f9ac439ca
2 changed files with 53 additions and 8 deletions
|
@ -22,7 +22,11 @@ var quoteRegexp = regexp.MustCompile(`["'][\s\S]+?["']`)
|
|||
func CreateReader(input io.Reader, delimiter rune) *stdcsv.Reader {
|
||||
rd := stdcsv.NewReader(input)
|
||||
rd.Comma = delimiter
|
||||
rd.TrimLeadingSpace = true
|
||||
if delimiter != '\t' && delimiter != ' ' {
|
||||
// TrimLeadingSpace can't be true when delimiter is a tab or a space as the value for a column might be empty,
|
||||
// thus would change `\t\t` to just `\t` or ` ` (two spaces) to just ` ` (single space)
|
||||
rd.TrimLeadingSpace = true
|
||||
}
|
||||
return rd
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue