commit | a60e709ac81a100c95a2a09da877d2acd4f36b97 | [log] [tgz] |
---|---|---|
author | Damien Neil <dneil@google.com> | Tue Jan 28 14:53:44 2020 -0800 |
committer | Damien Neil <dneil@google.com> | Tue Jan 28 23:27:58 2020 +0000 |
tree | 49b24c03d3b509454ea0acf46ea8c79240aff1b6 | |
parent | cb0bfd0f407cb799143a95fe378f07164f4d0a65 [diff] [blame] |
proto: fix DiscardUnknown UnmarshalOptions.DiscardUnknown was simply not working. Oops. Fix it. Add a test. Change-Id: I76888eae1221d99a007f0e9cdb711d292e6856b1 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/216762 Reviewed-by: Joe Tsai <joetsai@google.com>
diff --git a/proto/decode.go b/proto/decode.go index 83942ea..9a6b2f7 100644 --- a/proto/decode.go +++ b/proto/decode.go
@@ -154,7 +154,9 @@ if valLen < 0 { return wire.ParseError(valLen) } - m.SetUnknown(append(m.GetUnknown(), b[:tagLen+valLen]...)) + if !o.DiscardUnknown { + m.SetUnknown(append(m.GetUnknown(), b[:tagLen+valLen]...)) + } } b = b[tagLen+valLen:] }