mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 22:44:29 +01:00
* Move TagHelpers to Abstractions Makes them available for use in plugins. Also cleans up the tag helper references in the view code: As we have it in the root view imports, the individual directives in the views are superfluous. * Move CurrenciesSuggestionsTagHelper back To get rid of the Rating dependency in Abstractions.
26 lines
775 B
C#
26 lines
775 B
C#
using System.Threading.Tasks;
|
|
using BTCPayServer.Security;
|
|
using Microsoft.AspNetCore.Razor.TagHelpers;
|
|
|
|
namespace BTCPayServer.Abstractions.TagHelpers;
|
|
|
|
/// <summary>
|
|
/// Add sha256- to allow inline event handlers in CSP
|
|
/// </summary>
|
|
[HtmlTargetElement("template", Attributes = "csp-allow")]
|
|
public class CSPTemplate : TagHelper
|
|
{
|
|
private readonly ContentSecurityPolicies _csp;
|
|
public CSPTemplate(ContentSecurityPolicies csp)
|
|
{
|
|
_csp = csp;
|
|
}
|
|
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
|
|
{
|
|
output.Attributes.RemoveAll("csp-allow");
|
|
var childContent = await output.GetChildContentAsync();
|
|
var content = childContent.GetContent();
|
|
_csp.AllowInline(content);
|
|
}
|
|
}
|