2019-08-10 14:05:11 +09:00
|
|
|
using Ganss.XSS;
|
|
|
|
using Microsoft.AspNetCore.Html;
|
|
|
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
|
|
|
|
2022-04-26 03:28:49 +02:00
|
|
|
namespace BTCPayServer.Abstractions.Services
|
2019-08-10 14:05:11 +09:00
|
|
|
{
|
|
|
|
public class Safe
|
|
|
|
{
|
|
|
|
private readonly IHtmlHelper _htmlHelper;
|
|
|
|
private readonly IJsonHelper _jsonHelper;
|
|
|
|
private readonly HtmlSanitizer _htmlSanitizer;
|
|
|
|
|
|
|
|
public Safe(IHtmlHelper htmlHelper, IJsonHelper jsonHelper, HtmlSanitizer htmlSanitizer)
|
|
|
|
{
|
|
|
|
_htmlHelper = htmlHelper;
|
|
|
|
_jsonHelper = jsonHelper;
|
|
|
|
_htmlSanitizer = htmlSanitizer;
|
|
|
|
}
|
|
|
|
|
|
|
|
public IHtmlContent Raw(string value)
|
|
|
|
{
|
|
|
|
return _htmlHelper.Raw(_htmlSanitizer.Sanitize(value));
|
|
|
|
}
|
|
|
|
|
|
|
|
public IHtmlContent Json(object model)
|
|
|
|
{
|
|
|
|
return _htmlHelper.Raw(_jsonHelper.Serialize(model));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|