Commit 6e16037c authored by Jon Skeet's avatar Jon Skeet

Address review comments.

parent 5bdc5729
...@@ -629,5 +629,27 @@ namespace Google.Protobuf ...@@ -629,5 +629,27 @@ namespace Google.Protobuf
var data = new byte[] { 130, 3, 1 }; var data = new byte[] { 130, 3, 1 };
Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseFrom(data)); Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseFrom(data));
} }
/// <summary>
/// Demonstrates current behaviour with an extraneous end group tag - see issue 688
/// for details; we may want to change this.
/// </summary>
[Test]
public void ExtraEndGroupSkipped()
{
var message = SampleMessages.CreateFullTestAllTypes();
var stream = new MemoryStream();
var output = new CodedOutputStream(stream);
output.WriteTag(100, WireFormat.WireType.EndGroup);
output.WriteTag(TestAllTypes.SingleFixed32FieldNumber, WireFormat.WireType.Fixed32);
output.WriteFixed32(123);
output.Flush();
stream.Position = 0;
var parsed = TestAllTypes.Parser.ParseFrom(stream);
Assert.AreEqual(new TestAllTypes { SingleFixed32 = 123 }, parsed);
}
} }
} }
...@@ -346,7 +346,7 @@ namespace Google.Protobuf ...@@ -346,7 +346,7 @@ namespace Google.Protobuf
switch (WireFormat.GetTagWireType(lastTag)) switch (WireFormat.GetTagWireType(lastTag))
{ {
case WireFormat.WireType.StartGroup: case WireFormat.WireType.StartGroup:
ConsumeGroup(); SkipGroup();
break; break;
case WireFormat.WireType.EndGroup: case WireFormat.WireType.EndGroup:
// Just ignore; there's no data following the tag. // Just ignore; there's no data following the tag.
...@@ -367,7 +367,7 @@ namespace Google.Protobuf ...@@ -367,7 +367,7 @@ namespace Google.Protobuf
} }
} }
private void ConsumeGroup() private void SkipGroup()
{ {
// Note: Currently we expect this to be the way that groups are read. We could put the recursion // Note: Currently we expect this to be the way that groups are read. We could put the recursion
// depth changes into the ReadTag method instead, potentially... // depth changes into the ReadTag method instead, potentially...
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment