8737dac caused a regression where the functionality of Trim changed with an invalid cutset.
Consider the following test:
func Test(t *testing.T) {
s1 := strings.Trim("\x80test\xff", "\xff")
s2 := bytes.Trim([]byte("\x80test\xff"), "\xff")
if s1 != string(s2) {
t.Errorf("Trim() = %q, want %q", s1, s2)
}
}
On Go 1.7, this passes with s1==s2=="test"
On tip, this fails with s1=="\x80test\xff" and s2=="test"
The string passed into the cutset is an invalid UTF-8 string, but I have actually seen a few instances of this in production code (filed a lint check for this: golang/lint#252). Regardless, the behavior of this edge case should be preserved from Go 1.7 to Go 1.8.
\cc @bradfitz @hirochachacha
8737dac caused a regression where the functionality of Trim changed with an invalid cutset.
Consider the following test:
On Go 1.7, this passes with
s1==s2=="test"On tip, this fails with
s1=="\x80test\xff"ands2=="test"The string passed into the cutset is an invalid UTF-8 string, but I have actually seen a few instances of this in production code (filed a lint check for this: golang/lint#252). Regardless, the behavior of this edge case should be preserved from Go 1.7 to Go 1.8.
\cc @bradfitz @hirochachacha