proto: validate UTF-8 in proto3 strings
Change-Id: I6a495730c3f438e7b2c4ca86edade7d6f25aa47d
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/171700
Reviewed-by: Herbie Ong <herbie@google.com>
diff --git a/encoding/textpb/encode_test.go b/encoding/textpb/encode_test.go
index 3397d66..41cae94 100644
--- a/encoding/textpb/encode_test.go
+++ b/encoding/textpb/encode_test.go
@@ -5,6 +5,7 @@
package textpb_test
import (
+ "bytes"
"encoding/hex"
"math"
"strings"
@@ -1248,7 +1249,7 @@
},
input: func() proto.Message {
m := &pb3.Nested{
- SString: "abc\xff",
+ SString: "abcd",
}
b, err := proto.MarshalOptions{Deterministic: true}.Marshal(m)
if err != nil {
@@ -1256,7 +1257,7 @@
}
return &knownpb.Any{
TypeUrl: string(m.ProtoReflect().Type().FullName()),
- Value: b,
+ Value: bytes.Replace(b, []byte("abcd"), []byte("abc\xff"), -1),
}
}(),
want: `[pb3.Nested]: {