#659 Parse headers with consecutive commas
This commit is contained in:
parent
20d608170e
commit
3c0c02112d
|
|
@ -188,6 +188,9 @@ namespace Microsoft.AspNetCore.Http.Internal
|
|||
switch (attr)
|
||||
{
|
||||
case Attr.Delimiter:
|
||||
_valueStart = _valueStart == -1 ? _offset : _valueStart;
|
||||
_valueEnd = _valueEnd == -1 ? _offset : _valueEnd;
|
||||
_trailingStart = _trailingStart == -1 ? _offset : _trailingStart;
|
||||
_leadingEnd = _offset;
|
||||
_mode = Mode.Produce;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,14 @@ namespace Microsoft.AspNetCore.Http
|
|||
{
|
||||
public class HeaderDictionaryTests
|
||||
{
|
||||
public static TheoryData HeaderSegmentData => new TheoryData<IEnumerable<string>>
|
||||
{
|
||||
new[] { "Value1", "Value2", "Value3", "Value4" },
|
||||
new[] { "Value1", "", "Value3", "Value4" },
|
||||
new[] { "Value1", "", "", "Value4" },
|
||||
new[] { "", "", "", "" }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void PropertiesAreAccessible()
|
||||
{
|
||||
|
|
@ -26,5 +34,22 @@ namespace Microsoft.AspNetCore.Http
|
|||
Assert.Equal("Value1", headers["header1"]);
|
||||
Assert.Equal(new[] { "Value1" }, headers["header1"].ToArray());
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(HeaderSegmentData))]
|
||||
public void EmptyHeaderSegmentsAreParsable(IEnumerable<string> segments)
|
||||
{
|
||||
var header = string.Join(",", segments);
|
||||
|
||||
var headers = new HeaderDictionary(
|
||||
new Dictionary<string, StringValues>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
{ "Header1", header},
|
||||
});
|
||||
|
||||
var result = headers.GetCommaSeparatedValues("Header1");
|
||||
|
||||
Assert.Equal(segments, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue