This commit is contained in:
parent
3fa10f92ad
commit
0452f460c6
|
|
@ -209,6 +209,7 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||||
case ArgumentsPropertyName:
|
case ArgumentsPropertyName:
|
||||||
JsonUtils.CheckRead(reader);
|
JsonUtils.CheckRead(reader);
|
||||||
|
|
||||||
|
int initialDepth = reader.Depth;
|
||||||
if (reader.TokenType != JsonToken.StartArray)
|
if (reader.TokenType != JsonToken.StartArray)
|
||||||
{
|
{
|
||||||
throw new InvalidDataException($"Expected '{ArgumentsPropertyName}' to be of type {JTokenType.Array}.");
|
throw new InvalidDataException($"Expected '{ArgumentsPropertyName}' to be of type {JTokenType.Array}.");
|
||||||
|
|
@ -231,6 +232,14 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
argumentBindingException = ExceptionDispatchInfo.Capture(ex);
|
argumentBindingException = ExceptionDispatchInfo.Capture(ex);
|
||||||
|
|
||||||
|
// Could be at any point in argument array JSON when an error is thrown
|
||||||
|
// Read until the end of the argument JSON array
|
||||||
|
while (reader.Depth == initialDepth && reader.TokenType == JsonToken.StartArray ||
|
||||||
|
reader.Depth > initialDepth)
|
||||||
|
{
|
||||||
|
JsonUtils.CheckRead(reader);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -291,6 +291,18 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol
|
||||||
Assert.Equal(DateTimeKind.Utc, dt.Kind);
|
Assert.Equal(DateTimeKind.Utc, dt.Kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ReadToEndOfArgumentArrayOnError()
|
||||||
|
{
|
||||||
|
var binder = new TestBinder(new[] { typeof(string) });
|
||||||
|
var protocol = new JsonHubProtocol();
|
||||||
|
var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(Frame("{'type':1,'invocationId':'42','target':'foo','arguments':[[],{'target':'foo2'}]}")));
|
||||||
|
protocol.TryParseMessage(ref data, binder, out var message);
|
||||||
|
var bindingFailure = Assert.IsType<InvocationBindingFailureMessage>(message);
|
||||||
|
|
||||||
|
Assert.Equal("foo", bindingFailure.Target);
|
||||||
|
}
|
||||||
|
|
||||||
private static string Frame(string input)
|
private static string Frame(string input)
|
||||||
{
|
{
|
||||||
var data = Encoding.UTF8.GetBytes(input);
|
var data = Encoding.UTF8.GetBytes(input);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue