Fix for Issue#5150
This commit is contained in:
parent
61de7fec6f
commit
38aa48651f
|
|
@ -308,7 +308,7 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
|
||||
// We check if the parsed media type has value at this stage when we have iterated
|
||||
// over all the parameters and we know if the parsing was sucessful.
|
||||
if (!parser.ParsingFailed)
|
||||
if (!parser.ParsingFailed && parser.CurrentOffset >= start)
|
||||
{
|
||||
return new MediaTypeSegmentWithQuality(
|
||||
new StringSegment(mediaType, start, parser.CurrentOffset - start),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using Xunit;
|
||||
|
|
@ -48,6 +49,21 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Internal
|
|||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseAcceptHeader_ParsesSimpleHeaderWithMultipleValues_InvalidFormat()
|
||||
{
|
||||
// Arrange
|
||||
var header = "application/json, application/xml,;q=0.8";
|
||||
var expectedException = "\"Invalid values ';q=0.8'.\"";
|
||||
|
||||
// Act
|
||||
var ex = Assert.Throws<FormatException>(
|
||||
() => { AcceptHeaderParser.ParseAcceptHeader(new List<string> { header }); });
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expectedException, ex.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParseAcceptHeader_ParsesMultipleHeaderValues()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue