Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Fix Money#to_html sanitization
Damian Legawiec7c33ae11e907
diff --git a/backend/engines/core/lib/spree/money.rb b/backend/engines/core/lib/spree/money.rbindex 6a98741f53..8a1e7b24ef 100644--- a/backend/engines/core/lib/spree/money.rb+++ b/backend/engines/core/lib/spree/money.rb@@ -51,17 +51,10 @@ module Spree# 1) prevent blank, breaking spaces# 2) prevent escaping of HTML character entitiesdef to_html(opts = { html: true })- # html option is deprecated and we need to fallback to html_wrap- opts[:html_wrap] = opts[:html]opts.delete(:html)- output = money.format(options.merge(opts))- if opts[:html_wrap]- output.gsub!(/<\/?[^>]*>/, '') # we don't want wrap every element in span- output = output.sub(' ', ' ').html_safe- end-- output+ output = money.format(options.merge(opts).merge(html_wrap: false))+ output.sub(' ', ' ').html_safeenddef as_json(*)diff --git a/backend/engines/core/spec/helpers/products_helper_spec.rb b/backend/engines/core/spec/helpers/products_helper_spec.rbindex fca81b12ee..b325fef730 100644--- a/backend/engines/core/spec/helpers/products_helper_spec.rb+++ b/backend/engines/core/spec/helpers/products_helper_spec.rb@@ -61,13 +61,13 @@ module Spreecontext 'when variant is more than master' dolet(:variant_price) { 150 }- it { is_expected.to eq('(Add: ¥50)') }+ it { is_expected.to eq("(Add: \u00A550)") }endcontext 'when variant is less than master' dolet(:product_price) { 150 }- it { is_expected.to eq('(Subtract: ¥50)') }+ it { is_expected.to eq("(Subtract: \u00A550)") }endendend@@ -104,7 +104,7 @@ module Spreeit 'returns the variant price if the price is different than master' doproduct.price = 100@variant1.price = 150- expect(helper.variant_price(@variant1)).to eq('¥150')+ expect(helper.variant_price(@variant1)).to eq("\u00A5150")endend