aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/csv/reader_test.go
diff options
context:
space:
mode:
authorJustin Nuß <nuss.justin@gmail.com>2017-08-02 19:46:41 +0200
committerIan Lance Taylor <iant@golang.org>2017-08-14 18:42:20 +0000
commit9fbc06e6aa88372a449b75b35420e83ffce05a0b (patch)
tree34876c9dc982dcd68a8c3233b91da2d461797c3d /src/encoding/csv/reader_test.go
parentf9cf8e5ab11c7ea3f1b9fde302c0a325df020b1a (diff)
downloadgo-9fbc06e6aa88372a449b75b35420e83ffce05a0b.tar.xz
encoding/csv: preserve \r\n in quoted fields
The parser mistakenly assumed it could always fold \r\n into \n, which is not true since a \r\n inside a quoted fields has no special meaning and should be kept as is. Fix this by not folding \r\n to \n inside quotes fields. Fixes #21201 Change-Id: Ifebc302e49cf63e0a027ee90f088dbc050a2b7a6 Reviewed-on: https://go-review.googlesource.com/52810 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/encoding/csv/reader_test.go')
-rw-r--r--src/encoding/csv/reader_test.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/encoding/csv/reader_test.go b/src/encoding/csv/reader_test.go
index 76e94bab3e..3811629aad 100644
--- a/src/encoding/csv/reader_test.go
+++ b/src/encoding/csv/reader_test.go
@@ -284,6 +284,13 @@ x,,,
Line: 2,
Column: 2,
},
+ { // issue 21201
+ Name: "CRLFInQuotedField",
+ Input: "\"Hello\r\nHi\"",
+ Output: [][]string{
+ {"Hello\r\nHi"},
+ },
+ },
}
func TestRead(t *testing.T) {