diff options
| author | Martin Möhrmann <moehrmann@google.com> | 2018-05-04 06:54:18 +0200 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2018-05-04 05:37:45 +0000 |
| commit | 8c62fc0ca3c96ecbd3a6e81546aa8c53e32ff500 (patch) | |
| tree | 4f312eb8a09a81c8c2e083d9425c6a12fd180dd5 /src/strings/strings.go | |
| parent | 98409a44d5e971f4ffd485dfb130a8521caa7355 (diff) | |
| download | go-8c62fc0ca3c96ecbd3a6e81546aa8c53e32ff500.tar.xz | |
strings: fix encoding of \u0080 in map
Fix encoding of PAD (U+0080) which has the same value as utf8.RuneSelf
being incorrectly encoded as \x80 in strings.Map due to using <= instead
of a < comparison operator to check one byte encodings for utf8.
Fixes #25242
Change-Id: Ib6c7d1f425a7ba81e431b6d64009e713d94ea3bc
Reviewed-on: https://go-review.googlesource.com/111286
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/strings/strings.go')
| -rw-r--r-- | src/strings/strings.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/strings/strings.go b/src/strings/strings.go index 45345e0088..adbbe742fc 100644 --- a/src/strings/strings.go +++ b/src/strings/strings.go @@ -479,7 +479,7 @@ func Map(mapping func(rune) rune, s string) string { b = make([]byte, len(s)+utf8.UTFMax) nbytes = copy(b, s[:i]) if r >= 0 { - if r <= utf8.RuneSelf { + if r < utf8.RuneSelf { b[nbytes] = byte(r) nbytes++ } else { @@ -509,7 +509,7 @@ func Map(mapping func(rune) rune, s string) string { r := mapping(c) // common case - if (0 <= r && r <= utf8.RuneSelf) && nbytes < len(b) { + if (0 <= r && r < utf8.RuneSelf) && nbytes < len(b) { b[nbytes] = byte(r) nbytes++ continue |
