Skip to content

Commit

Permalink
Prevent API compatibility errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahelsaig committed Feb 21, 2024
1 parent 774b1df commit 1518682
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ public interface IContentSecurityPolicyProvider
/// </summary>
public ValueTask UpdateAsync(IDictionary<string, string> securityPolicies, HttpContext context);

[Obsolete($"Use the method in the {nameof(ContentSecurityPolicyProvider)} static class instead.")]
public static string GetDirective(IDictionary<string, string> securityPolicies, params string[] names) =>
ContentSecurityPolicyProvider.GetDirective(securityPolicies, names.AsEnumerable());
}

public static class ContentSecurityPolicyProvider
{
/// <summary>
/// Returns the first non-empty directive from the <paramref name="names"/> or <see cref="DefaultSrc"/> or an empty
/// string.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public ValueTask UpdateAsync(IDictionary<string, string> securityPolicies, HttpC
{
foreach (var attribute in actionDescriptor.MethodInfo.GetCustomAttributes<ContentSecurityPolicyAttribute>())
{
IContentSecurityPolicyProvider.MergeDirectiveValues(
ContentSecurityPolicyProvider.MergeDirectiveValues(
securityPolicies,
attribute.DirectiveNames,
attribute.DirectiveValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public ValueTask UpdateAsync(IDictionary<string, string> securityPolicies, HttpC

if (resourceExists)
{
IContentSecurityPolicyProvider.MergeDirectiveValues(securityPolicies, DirectiveNameChain, DirectiveValue);
ContentSecurityPolicyProvider.MergeDirectiveValues(securityPolicies, DirectiveNameChain, DirectiveValue);
}

return ThenUpdateAsync(securityPolicies, context, resourceExists);
Expand Down

0 comments on commit 1518682

Please sign in to comment.