From 9a4685f22036b4e2577bb79dbfabd7c4e48146e3 Mon Sep 17 00:00:00 2001 From: Joe Tsai Date: Wed, 22 Jun 2022 20:57:50 -0700 Subject: strings: avoid utf8.RuneError mangling in Split Split should only split strings and not perform mangling of invalid UTF-8 into ut8.RuneError. The prior behavior is clearly a bug since mangling is not performed in all other situations (e.g., separator is non-empty). Fixes #53511 Change-Id: I112a2ef15ee46ddecda015ee14bca04cd76adfbf Reviewed-on: https://go-review.googlesource.com/c/go/+/413715 Reviewed-by: Dmitri Shuralyov Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor TryBot-Result: Gopher Robot --- src/strings/strings_test.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/strings/strings_test.go') diff --git a/src/strings/strings_test.go b/src/strings/strings_test.go index 9e7fb85ddf..a1604c2c47 100644 --- a/src/strings/strings_test.go +++ b/src/strings/strings_test.go @@ -406,6 +406,8 @@ var splittests = []SplitTest{ {"1 2 3 4", " ", 3, []string{"1", "2", "3 4"}}, {"1 2", " ", 3, []string{"1", "2"}}, {"", "T", math.MaxInt / 4, []string{""}}, + {"\xff-\xff", "", -1, []string{"\xff", "-", "\xff"}}, + {"\xff-\xff", "-", -1, []string{"\xff", "\xff"}}, } func TestSplit(t *testing.T) { -- cgit v1.3