From 688e873f7a4d7fc79dc3be891126b889e4da9d68 Mon Sep 17 00:00:00 2001 From: Kukks Date: Sat, 29 Jul 2023 09:13:53 +0200 Subject: [PATCH] fixes #5203 --- BTCPayServer.Abstractions/Services/Safe.cs | 5 +++++ .../Views/Shared/PointOfSale/Public/Cart.cshtml | 14 ++++++++------ BTCPayServer/wwwroot/pos/cart.js | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/BTCPayServer.Abstractions/Services/Safe.cs b/BTCPayServer.Abstractions/Services/Safe.cs index 8ddb7b9a4..cb8a22d82 100644 --- a/BTCPayServer.Abstractions/Services/Safe.cs +++ b/BTCPayServer.Abstractions/Services/Safe.cs @@ -1,3 +1,4 @@ +using System.Web; using Ganss.XSS; using Microsoft.AspNetCore.Html; using Microsoft.AspNetCore.Mvc.Rendering; @@ -21,6 +22,10 @@ namespace BTCPayServer.Abstractions.Services { return _htmlHelper.Raw(_htmlSanitizer.Sanitize(value)); } + public IHtmlContent RawEncode(string value) + { + return _htmlHelper.Raw(HttpUtility.HtmlEncode(_htmlSanitizer.Sanitize(value))); + } public IHtmlContent Json(object model) { diff --git a/BTCPayServer/Views/Shared/PointOfSale/Public/Cart.cshtml b/BTCPayServer/Views/Shared/PointOfSale/Public/Cart.cshtml index aef4b0324..75155095b 100644 --- a/BTCPayServer/Views/Shared/PointOfSale/Public/Cart.cshtml +++ b/BTCPayServer/Views/Shared/PointOfSale/Public/Cart.cshtml @@ -1,6 +1,8 @@ @using BTCPayServer.Plugins.PointOfSale.Models @using BTCPayServer.Services @using Newtonsoft.Json.Linq; +@using BTCPayServer.Abstractions.TagHelpers +@using Microsoft.AspNetCore.Mvc.TagHelpers @inject DisplayFormatter DisplayFormatter @inject BTCPayServer.Security.ContentSecurityPolicies Csp @model BTCPayServer.Plugins.PointOfSale.Models.ViewPointOfSaleViewModel @@ -63,15 +65,15 @@ ? item.PriceType == ViewPointOfSaleViewModel.ItemPriceType.Topup ? Model.CustomButtonText : Model.ButtonText : item.BuyButtonText; buttonText = buttonText.Replace("{0}", formatted).Replace("{Price}", formatted); - -
+ var categories = new JArray(item.Categories ?? Array.Empty()); +
@if (!string.IsNullOrWhiteSpace(item.Image)) { - @Safe.Raw(item.Title) + @item.Title }
-
@Safe.Raw(item.Title)
+
@Safe.RawEncode(item.Title)
@if (item.PriceType == ViewPointOfSaleViewModel.ItemPriceType.Topup || item.Price == 0) { @@ -90,14 +92,14 @@
@if (!string.IsNullOrWhiteSpace(item.Description)) { -

@Safe.Raw(item.Description)

+

@Safe.RawEncode(item.Description)

}
@if (inStock) {
diff --git a/BTCPayServer/wwwroot/pos/cart.js b/BTCPayServer/wwwroot/pos/cart.js index 01fa712f4..ccb1863a2 100644 --- a/BTCPayServer/wwwroot/pos/cart.js +++ b/BTCPayServer/wwwroot/pos/cart.js @@ -70,7 +70,7 @@ document.addEventListener("DOMContentLoaded",function () { searchTerm(term) { const t = term.toLowerCase(); this.forEachItem(item => { - const terms = item.dataset.search.toLowerCase() + const terms = decodeURIComponent(item.dataset.search.toLowerCase()); const included = terms.indexOf(t) !== -1 item.classList[included ? 'remove' : 'add']("d-none") })