Skip to content

Commit

Permalink
Update ReadAny to skip over lists and maps (#372)
Browse files Browse the repository at this point in the history
* Normalize line endings

* Skip over List and Map encountered by ReadAny
  • Loading branch information
ngbrown committed Apr 12, 2024
1 parent f2904b0 commit df102c4
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto

*.sln text eol=crlf
*.csproj text eol=crlf
*.vbproj text eol=crlf
*.vcxproj text eol=crlf
*.vcproj text eol=crlf
*.dbproj text eol=crlf
*.fsproj text eol=crlf
*.lsproj text eol=crlf
*.wixproj text eol=crlf
*.modelproj text eol=crlf
*.sqlproj text eol=crlf
*.wmaproj text eol=crlf

*.xproj text eol=crlf
*.props text eol=crlf
*.filters text eol=crlf
*.vcxitems text eol=crlf
*.dgml text eol=crlf

*.bat text eol=crlf
*.cmd text eol=crlf
*.sh text eol=lf

*.DotSettings text eol=lf
*.svg text eol=lf
*.kts text eol=lf

*.cs diff=csharp
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

*.exe binary
*.pdf binary
*.bmp binary
*.cur binary
*.dll binary
*.doc binary
*.docx binary
*.ico binary
*.jpg binary
*.ocx binary
*.xls binary
*.xlsx binary
*.png binary
*.gif binary
29 changes: 29 additions & 0 deletions RabbitMQ.Stream.Client/AMQP/AmqpWireFormattingRead.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,35 @@ internal static int ReadAny(ref SequenceReader<byte> reader, out object value)
value = null;
reader.Advance(1);
return 1;

case FormatCode.List0:
case FormatCode.List8:
case FormatCode.List32:
{
offset = ReadListHeader(ref reader, out var fields);
for (long i = 0; i < fields; i++)
{
offset += ReadAny(ref reader, out _);
}

value = null;
return offset;
}

case FormatCode.Map8:
case FormatCode.Map32:
{
offset = ReadMapHeader(ref reader, out var count);
var values = count / 2;
for (uint i = 0; i < values; i++)
{
offset += ReadAny(ref reader, out _);
offset += ReadAny(ref reader, out _);
}

value = null;
return offset;
}
}

throw new AmqpParseException($"Read Any: Invalid type: {type}");
Expand Down

0 comments on commit df102c4

Please sign in to comment.