Skip to content

strings: Map does not handle invalid UTF-8 correctly #26305

Description

@rsc

Map's loop does:

for i, c := range s {
	r := mapping(c)
	if r == c {

This is wrong if r is the error rune because s has invalid UTF-8. The loop should check this and flip to rewriting the string in that case.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions