Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Commit 2a6d771

Browse files
committed
Feedback
1 parent de30c5e commit 2a6d771

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/Microsoft.AspNetCore.Http.Abstractions/Internal/ParsingHelpers.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@ private static IEnumerable<string> GetHeaderSplitImplementation(StringValues val
2626
{
2727
foreach (var segment in new HeaderSegmentCollection(values))
2828
{
29-
if (segment.Data.HasValue && !StringSegment.IsNullOrEmpty(segment.Data))
29+
if (!StringSegment.IsNullOrEmpty(segment.Data))
3030
{
31-
yield return DeQuote(segment.Data.Value);
31+
var value = DeQuote(segment.Data.Value);
32+
if (!string.IsNullOrEmpty(value))
33+
{
34+
yield return value;
35+
}
3236
}
3337
}
3438
}

test/Microsoft.AspNetCore.Http.Tests/HeaderDictionaryTests.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void PropertiesAreAccessible()
4040

4141
[Theory]
4242
[MemberData(nameof(HeaderSegmentData))]
43-
public void EmptyHeaderSegmentsAreParsable(IEnumerable<string> segments)
43+
public void EmptyHeaderSegmentsAreIgnored(IEnumerable<string> segments)
4444
{
4545
var header = string.Join(",", segments);
4646

@@ -51,9 +51,22 @@ public void EmptyHeaderSegmentsAreParsable(IEnumerable<string> segments)
5151
});
5252

5353
var result = headers.GetCommaSeparatedValues("Header1");
54-
var expectedResult = segments.Where(s => !string.IsNullOrWhiteSpace(s));
54+
var expectedResult = segments.Where(s => !string.IsNullOrEmpty(s));
5555

5656
Assert.Equal(expectedResult, result);
5757
}
58+
59+
[Fact]
60+
public void EmtpyQuotedHeaderSegmentsAreIgnored()
61+
{
62+
var headers = new HeaderDictionary(
63+
new Dictionary<string, StringValues>(StringComparer.OrdinalIgnoreCase)
64+
{
65+
{ "Header1", "Value1,\"\",,Value2" },
66+
});
67+
68+
var result = headers.GetCommaSeparatedValues("Header1");
69+
Assert.Equal(new[] { "Value1", "Value2" }, result);
70+
}
5871
}
5972
}

0 commit comments

Comments
 (0)