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

strconv: Unquote preserves literal carriage returns in raw string literals #15997

Closed
mdempsky opened this issue Jun 7, 2016 · 2 comments
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@mdempsky
Copy link
Member

mdempsky commented Jun 7, 2016

Package strconv says:

Unquote interprets s as a single-quoted, double-quoted, or backquoted Go string literal, returning the string value that s quotes.

I understand "backquoted Go string literal" to mean what the Go spec calls a "raw string literal". Also, according to the Go spec:

Carriage return characters ('\r') inside raw string literals are discarded from the raw string value.

However, it seems that strconv.Unquote keeps carriage return characters rather than discarding them: https://play.golang.org/p/G-4x0-Mdop (Note that the \r escape sequence is interpreted by the Go interpreted string literal, so the string value seen by strconv.Unquote is the three byte sequence: GRAVE ACCENT, CARRIAGE RETURN, GRAVE ACCENT.)

It may be too late to change strconv.Unquote's behavior, but perhaps the existing behavior can be better documented at least.

@mdempsky mdempsky added this to the Go1.8 milestone Jun 7, 2016
@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 10, 2016
@rsc
Copy link
Contributor

rsc commented Oct 13, 2016

OK, let's make it match the spec.

@gopherbot
Copy link

CL https://golang.org/cl/31210 mentions this issue.

@golang golang locked and limited conversation to collaborators Oct 17, 2017
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

4 participants