Remove redundant HTML sanitisation

We don't need to run the sanitiser each time we read an attribute. It's
a waste of time.
This commit is contained in:
Maikel Linke
2024-10-24 08:46:33 +11:00
parent 169e1cf288
commit d2e5087668
6 changed files with 0 additions and 30 deletions

View File

@@ -5,11 +5,6 @@ class CustomTab < ApplicationRecord
validates :title, presence: true, length: { maximum: 20 }
# Remove any unsupported HTML.
def content
HtmlSanitizer.sanitize(super)
end
# Remove any unsupported HTML.
def content=(html)
super(HtmlSanitizer.sanitize(html))

View File

@@ -74,11 +74,6 @@ class EnterpriseGroup < ApplicationRecord
permalink
end
# Remove any unsupported HTML.
def long_description
HtmlSanitizer.sanitize_and_enforce_link_target_blank(super)
end
# Remove any unsupported HTML.
def long_description=(html)
super(HtmlSanitizer.sanitize_and_enforce_link_target_blank(html))

View File

@@ -279,11 +279,6 @@ module Spree
end
# rubocop:enable Metrics/AbcSize
# Remove any unsupported HTML.
def description
HtmlSanitizer.sanitize(super)
end
# Remove any unsupported HTML.
def description=(html)
super(HtmlSanitizer.sanitize(html))

View File

@@ -18,10 +18,5 @@ RSpec.describe CustomTab do
subject.content = "Hello <script>alert</script> dearest <b>monster</b>."
expect(subject.content).to eq "Hello alert dearest <b>monster</b>."
end
it "sanitises existing HTML in content" do
subject[:content] = "Hello <script>alert</script> dearest <b>monster</b>."
expect(subject.content).to eq "Hello alert dearest <b>monster</b>."
end
end
end

View File

@@ -124,10 +124,5 @@ RSpec.describe EnterpriseGroup do
subject.long_description = "Hello <script>alert</script> dearest <b>monster</b>."
expect(subject.long_description).to eq "Hello alert dearest <b>monster</b>."
end
it "sanitises existing HTML in long_description" do
subject[:long_description] = "Hello <script>alert</script> dearest <b>monster</b>."
expect(subject.long_description).to eq "Hello alert dearest <b>monster</b>."
end
end
end

View File

@@ -707,11 +707,6 @@ module Spree
subject.description = "Hello <script>alert</script> dearest <b>monster</b>."
expect(subject.description).to eq "Hello alert dearest <b>monster</b>."
end
it "sanitises existing HTML in description" do
subject[:description] = "Hello <script>alert</script> dearest <b>monster</b>."
expect(subject.description).to eq "Hello alert dearest <b>monster</b>."
end
end
end