aboutsummaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorRichard Mahn <richmahn@users.noreply.github.com>2021-10-30 09:50:40 -0600
committerGitHub <noreply@github.com>2021-10-30 23:50:40 +0800
commit40c8451b7d68614cc5d971cd148df503e7c00647 (patch)
tree83ce2c66ea9909decb692b3d4a5cf7c8ce2c6f10 /services
parent63c0dc89ef96a2e38b38aa6cba5e4e8d1d7b9150 (diff)
downloadgitea-40c8451b7d68614cc5d971cd148df503e7c00647.tar.gz
gitea-40c8451b7d68614cc5d971cd148df503e7c00647.zip
Properly determine CSV delimiter (#17459)
* Fixes #16558 CSV delimiter determiner * Fixes #16558 - properly determine CSV delmiiter * Moves quoteString to a new function * Adds big test with lots of commas for tab delimited csv * Adds comments * Shortens the text of the test * Removes single quotes from regexp as only double quotes need to be searched * Fixes spelling * Fixes check of length as it probalby will only be 1e4, not greater * Makes sample size a const, properly removes truncated line * Makes sample size a const, properly removes truncated line * Fixes comment * Fixes comment * tests for FormatError() function * Adds logic to find the limiter before or after a quoted value * Simplifies regex * Error tests * Error tests * Update modules/csv/csv.go Co-authored-by: delvh <dev.lh@web.de> * Update modules/csv/csv.go Co-authored-by: delvh <dev.lh@web.de> * Adds comments * Update modules/csv/csv.go Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: delvh <dev.lh@web.de>
Diffstat (limited to 'services')
-rw-r--r--services/gitdiff/csv_test.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/services/gitdiff/csv_test.go b/services/gitdiff/csv_test.go
index 1710e91c58..4101477d89 100644
--- a/services/gitdiff/csv_test.go
+++ b/services/gitdiff/csv_test.go
@@ -194,16 +194,16 @@ c,d,e`,
var baseReader *csv.Reader
if len(c.base) > 0 {
- baseReader, err = csv_module.CreateReaderAndGuessDelimiter(strings.NewReader(c.base))
+ baseReader, err = csv_module.CreateReaderAndDetermineDelimiter(nil, strings.NewReader(c.base))
if err != nil {
- t.Errorf("CreateReaderAndGuessDelimiter failed: %s", err)
+ t.Errorf("CreateReaderAndDetermineDelimiter failed: %s", err)
}
}
var headReader *csv.Reader
if len(c.head) > 0 {
- headReader, err = csv_module.CreateReaderAndGuessDelimiter(strings.NewReader(c.head))
+ headReader, err = csv_module.CreateReaderAndDetermineDelimiter(nil, strings.NewReader(c.head))
if err != nil {
- t.Errorf("CreateReaderAndGuessDelimiter failed: %s", err)
+ t.Errorf("CreateReaderAndDetermineDelimiter failed: %s", err)
}
}