From 3c3b889f467d14b835888453734fc899c5ca1d7b Mon Sep 17 00:00:00 2001 From: Zach Musgrave Date: Thu, 19 Dec 2024 15:59:31 -0800 Subject: [PATCH] Bug fix for windows line endings --- core/dataloader/csvreader.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/dataloader/csvreader.go b/core/dataloader/csvreader.go index 3c75f66cda..b220c67934 100644 --- a/core/dataloader/csvreader.go +++ b/core/dataloader/csvreader.go @@ -295,7 +295,10 @@ func (csvr *csvReader) parseQuotedField(rs *recordState) (kontinue bool, err err const quoteLen = len(`"`) dl := len(csvr.delim) recordStartLine := csvr.numLine - fullField := rs.line + // full copy needed here because we append rs.line to fullField, and this can result in buffer corruption in + // some cases (namely when windows line endings are present) + fullField := make([]byte, len(rs.line)) + copy(fullField, rs.line) // Quoted string field rs.line = rs.line[quoteLen:]