Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding/csv: regression in handling of '\n' delimiters #22404

Closed
dsnet opened this issue Oct 23, 2017 · 1 comment
Closed

encoding/csv: regression in handling of '\n' delimiters #22404

dsnet opened this issue Oct 23, 2017 · 1 comment
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@dsnet
Copy link
Member

dsnet commented Oct 23, 2017

Consider the following:

in := `line0
line1
line2
`
r := csv.NewReader(strings.NewReader(in))
r.Comma = '\n'
for {
	record, err := r.Read()
	if err != nil {
		break
	}
	fmt.Printf("%q\n", record)
}

Prior to CL 72150, this would print:

["line0"]
["line1"]
["line2"]

On tip, it prints:

["line0" ""]
["line1" ""]
["line2" ""]

It's not obvious to me what the correct behavior is, but someone was hacking abusing CSV to act a trivial parser to read a file as a slice of newline seperated items.

@dsnet dsnet changed the title encoding/csv: regression encoding/csv: regression in handling of Oct 23, 2017
@dsnet dsnet changed the title encoding/csv: regression in handling of encoding/csv: regression in handling of '\n' delimiters Oct 23, 2017
@dsnet dsnet added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Oct 23, 2017
@dsnet dsnet added this to the Go1.10 milestone Oct 23, 2017
@dsnet dsnet self-assigned this Oct 23, 2017
@gopherbot
Copy link

Change https://golang.org/cl/72793 mentions this issue: encoding/csv: forbid certain Comma and Comment runes

@dsnet dsnet added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. labels Oct 25, 2017
@golang golang locked and limited conversation to collaborators Oct 25, 2018
@rsc rsc unassigned dsnet Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

2 participants