Skip to content

strconv: Unquote inconsistently decodes invalid UTF-8 #23685

@bjkail

Description

@bjkail

What version of Go are you using (go version)?

Playground.

What did you do?

strconv.Unquote with a quoted string containing an invalid UTF-8 byte sequence and either an escape sequence or not: https://play.golang.org/p/VZUxFxt7gh9

What did you expect to see?

The same encoding of the invalid UTF-8 regardless of whether the string contains an escape sequence (probably a reencoding of RuneError in both cases), or documentation explaining there's a difference.

What did you see instead?

If the string does not contain an escape sequence, the invalid UTF-8 sequence is preserved.
If the string contains an escape sequence, the invalid UTF-8 sequence reencodes RuneError.

The trivial code path does not validate the UTF-8.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions