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
Allow only web images (#12175)
Damian Kaczmarczykb6a861116943
diff --git a/core/app/models/spree/image/configuration/active_storage.rb b/core/app/models/spree/image/configuration/active_storage.rbindex ccb4ea7da7..963cefead6 100644--- a/core/app/models/spree/image/configuration/active_storage.rb+++ b/core/app/models/spree/image/configuration/active_storage.rb@@ -5,7 +5,7 @@ module Spreeextend ActiveSupport::Concernincluded do- validates :attachment, attached: true, content_type: /\Aimage\/.*\z/+ validates :attachment, attached: true, content_type: Rails.application.config.active_storage.web_image_content_typesdef self.styles@styles ||= {diff --git a/core/app/models/spree/taxon_image/configuration/active_storage.rb b/core/app/models/spree/taxon_image/configuration/active_storage.rbindex 868014c7c7..dfcb16d972 100644--- a/core/app/models/spree/taxon_image/configuration/active_storage.rb+++ b/core/app/models/spree/taxon_image/configuration/active_storage.rb@@ -5,7 +5,7 @@ module Spreeextend ActiveSupport::Concernincluded do- validates :attachment, content_type: /\Aimage\/.*\z/+ validates :attachment, content_type: Rails.application.config.active_storage.web_image_content_typesdefault_scope { includes(attachment_attachment: :blob) }diff --git a/core/spec/models/spree/image_spec.rb b/core/spec/models/spree/image_spec.rbindex c401035841..590eafeed7 100644--- a/core/spec/models/spree/image_spec.rb+++ b/core/spec/models/spree/image_spec.rb@@ -16,12 +16,12 @@ describe Spree::Image, type: :model doexpect(spree_image).not_to be_validend- it 'has allowed attachment content type' do+ it 'allows only web image content types' dospree_image.attachment.attach(io: image_file, filename: 'thinking-cat.jpg', content_type: 'image/jpeg')expect(spree_image).to be_validend- it 'has no allowed attachment content type' do+ it 'does not allow non-web image content types' dospree_image.attachment.attach(io: text_file, filename: 'text-file.txt', content_type: 'text/plain')expect(spree_image).not_to be_validend