mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
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:
@@ -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))
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user