Fix: Impossible to see relative time of transaction in wallet list

This commit is contained in:
nicolas.dorier 2021-09-29 13:09:04 +09:00
parent ed1ec2300d
commit 6a28497d33
No known key found for this signature in database
GPG Key ID: 6618763EF09186FE
2 changed files with 14 additions and 7 deletions

View File

@ -75,14 +75,21 @@ namespace BTCPayServer.Security
/// Allow a specific script as event handler
/// </summary>
/// <param name="script"></param>
public void AllowUnsafeHashes(string script)
public void AllowUnsafeHashes(string script = null)
{
if (!allowUnsafeHashes)
{
if (script is null)
throw new ArgumentNullException(nameof(script));
var sha = GetSha256(script);
Add("script-src", $"'unsafe-hashes'");
allowUnsafeHashes = true;
}
if (script != null)
{
var sha = GetSha256(script);
Add("script-src", $"'sha256-{sha}'");
}
}
bool allowUnsafeHashes = false;
/// <summary>
/// Allow the injection of script tag with the following script
/// </summary>

View File

@ -136,7 +136,7 @@ namespace BTCPayServer.TagHelpers
var v = attr.Value.ToString();
if (v.StartsWith("javascript:", StringComparison.OrdinalIgnoreCase))
{
_csp.AllowInline(v);
_csp.AllowUnsafeHashes(v);
}
}
}