aboutsummaryrefslogtreecommitdiff
path: root/src/ProtocolBuffers/ExtendableBuilderLite.cs
diff options
context:
space:
mode:
authorcsharptest <roger@csharptest.net>2011-06-04 12:52:57 -0500
committerrogerk <devnull@localhost>2011-06-04 12:52:57 -0500
commit6da3170a953b38d2e454a3035ebc24ed1cd4803a (patch)
tree696207ccde20a4ff20c1ef0c0f603ca8c86ad440 /src/ProtocolBuffers/ExtendableBuilderLite.cs
parent17699c21f98bda5ca039be3f5d43c9b0aa462aea (diff)
downloadprotobuf-6da3170a953b38d2e454a3035ebc24ed1cd4803a.tar.gz
protobuf-6da3170a953b38d2e454a3035ebc24ed1cd4803a.tar.bz2
protobuf-6da3170a953b38d2e454a3035ebc24ed1cd4803a.zip
Packed and Unpacked parsing allow for all repeated, per 2.3
Diffstat (limited to 'src/ProtocolBuffers/ExtendableBuilderLite.cs')
-rw-r--r--src/ProtocolBuffers/ExtendableBuilderLite.cs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/ProtocolBuffers/ExtendableBuilderLite.cs b/src/ProtocolBuffers/ExtendableBuilderLite.cs
index bac82bcb..27cd3e3b 100644
--- a/src/ProtocolBuffers/ExtendableBuilderLite.cs
+++ b/src/ProtocolBuffers/ExtendableBuilderLite.cs
@@ -146,6 +146,31 @@ namespace Google.ProtocolBuffers
return input.SkipField();
IFieldDescriptorLite field = extension.Descriptor;
+
+
+ // Unknown field or wrong wire type. Skip.
+ if (field == null)
+ {
+ return input.SkipField();
+ }
+ WireFormat.WireType expectedType = field.IsPacked
+ ? WireFormat.WireType.LengthDelimited
+ : WireFormat.GetWireType(field.FieldType);
+ if (wireType != expectedType)
+ {
+ expectedType = WireFormat.GetWireType(field.FieldType);
+ if (wireType == expectedType)
+ {
+ //Allowed as of 2.3, this is unpacked data for a packed array
+ }
+ else if (field.IsRepeated && wireType == WireFormat.WireType.LengthDelimited &&
+ (expectedType == WireFormat.WireType.Varint || expectedType == WireFormat.WireType.Fixed32 || expectedType == WireFormat.WireType.Fixed64))
+ {
+ //Allowed as of 2.3, this is packed data for an unpacked array
+ }
+ else
+ return input.SkipField();
+ }
if (!field.IsRepeated && wireType != WireFormat.GetWireType(field.FieldType)) //invalid wire type
return input.SkipField();