Handle subtype with suffix being a subtype without a suffix (#1027)
This commit is contained in:
parent
f5adc2bc31
commit
80b6ae4eb4
|
|
@ -650,6 +650,7 @@ namespace Microsoft.Net.Http.Headers
|
|||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (set.Suffix.HasValue)
|
||||
{
|
||||
if (Suffix.HasValue)
|
||||
|
|
@ -663,7 +664,10 @@ namespace Microsoft.Net.Http.Headers
|
|||
}
|
||||
else
|
||||
{
|
||||
return set.SubType.Equals(SubType, StringComparison.OrdinalIgnoreCase);
|
||||
// If this subtype or suffix matches the subtype of the set,
|
||||
// it is considered a subtype.
|
||||
// Ex: application/json > application/val+json
|
||||
return MatchesEitherSubtypeOrSuffix(set);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -673,6 +677,12 @@ namespace Microsoft.Net.Http.Headers
|
|||
set.SubTypeWithoutSuffix.Equals(SubTypeWithoutSuffix, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private bool MatchesEitherSubtypeOrSuffix(MediaTypeHeaderValue set)
|
||||
{
|
||||
return set.SubType.Equals(SubType, StringComparison.OrdinalIgnoreCase) ||
|
||||
set.SubType.Equals(Suffix, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private bool MatchesParameters(MediaTypeHeaderValue set)
|
||||
{
|
||||
if (set._parameters != null && set._parameters.Count != 0)
|
||||
|
|
|
|||
|
|
@ -750,6 +750,8 @@ namespace Microsoft.Net.Http.Headers
|
|||
[InlineData("application/entity+json", "application/entity+json")]
|
||||
[InlineData("application/*+json", "application/entity+json")]
|
||||
[InlineData("application/*+json", "application/*+json")]
|
||||
[InlineData("application/json", "application/problem+json")]
|
||||
[InlineData("application/json", "application/vnd.restful+json")]
|
||||
[InlineData("application/*", "application/*+JSON")]
|
||||
[InlineData("application/vnd.github+json", "application/vnd.github+json")]
|
||||
[InlineData("application/*", "application/entity+JSON")]
|
||||
|
|
@ -774,6 +776,7 @@ namespace Microsoft.Net.Http.Headers
|
|||
[InlineData("application/*+*", "application/json")]
|
||||
[InlineData("application/entity+*", "application/entity+json")] // We don't allow suffixes to be wildcards
|
||||
[InlineData("application/*+*", "application/entity+json")] // We don't allow suffixes to be wildcards
|
||||
[InlineData("application/entity+json", "application/entity")]
|
||||
public void IsSubSetOfWithSuffixes_NegativeCases(string set, string subset)
|
||||
{
|
||||
// Arrange
|
||||
|
|
|
|||
Loading…
Reference in New Issue