mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-01-29 19:04:40 +01:00
HTML lang setting and Head tags for POS and Crowdfund public pages (#6229)
* HTML lang setting and Head tags for POS and Crowdfund public pages * updates #6229 * updates 6229 * resolve conflict * updated according to Nicolas' recommendations * updates #6229 * Add RawMeta method in safe.cs * ... * resolve conflicts * resolve conflict * resolve conflicts * Updates as Nicolas request * updates --------- Co-authored-by: d11n <mail@dennisreimann.de>
This commit is contained in:
@@ -16,6 +16,8 @@ namespace BTCPayServer.Abstractions.Services
|
||||
_htmlHelper = htmlHelper;
|
||||
_jsonHelper = jsonHelper;
|
||||
_htmlSanitizer = htmlSanitizer;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public IHtmlContent Raw(string value)
|
||||
@@ -32,5 +34,37 @@ namespace BTCPayServer.Abstractions.Services
|
||||
{
|
||||
return _htmlHelper.Raw(_jsonHelper.Serialize(model));
|
||||
}
|
||||
|
||||
public string RawMeta(string inputHtml, out bool isHtmlModified)
|
||||
{
|
||||
bool bHtmlModified;
|
||||
HtmlSanitizer _metaSanitizer = new HtmlSanitizer();
|
||||
|
||||
_metaSanitizer.AllowedTags.Clear();
|
||||
_metaSanitizer.AllowedTags.Add("meta");
|
||||
|
||||
_metaSanitizer.AllowedAttributes.Clear();
|
||||
_metaSanitizer.AllowedAttributes.Add("name");
|
||||
_metaSanitizer.AllowedAttributes.Add("http-equiv");
|
||||
_metaSanitizer.AllowedAttributes.Add("content");
|
||||
_metaSanitizer.AllowedAttributes.Add("value");
|
||||
_metaSanitizer.AllowedAttributes.Add("property");
|
||||
|
||||
_metaSanitizer.AllowDataAttributes = false;
|
||||
|
||||
_metaSanitizer.RemovingTag += (sender, e) => bHtmlModified = true;
|
||||
_metaSanitizer.RemovingAtRule += (sender, e) => bHtmlModified = true;
|
||||
_metaSanitizer.RemovingAttribute += (sender, e) => bHtmlModified = true;
|
||||
_metaSanitizer.RemovingComment += (sender, e) => bHtmlModified = true;
|
||||
_metaSanitizer.RemovingCssClass += (sender, e) => bHtmlModified = true;
|
||||
_metaSanitizer.RemovingStyle += (sender, e) => bHtmlModified = true;
|
||||
|
||||
bHtmlModified = false;
|
||||
|
||||
var sRet = _metaSanitizer.Sanitize(inputHtml);
|
||||
isHtmlModified = bHtmlModified;
|
||||
|
||||
return sRet;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user