mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Sanitize content with a new TrixScrubber
specifically made for trix editor with its allowed tags
This commit is contained in:
13
app/services/trix_scrubber.rb
Normal file
13
app/services/trix_scrubber.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class TrixScrubber < Rails::Html::PermitScrubber
|
||||
ALLOWED_TAGS = ["p", "b", "strong", "em", "i", "a", "u", "br", "del", "h1", "blockquote", "pre",
|
||||
"ul", "ol", "li"].freeze
|
||||
ALLOWED_ATTRIBUTES = ["href", "target", "src", "alt"].freeze
|
||||
|
||||
def initialize
|
||||
super
|
||||
self.tags = ALLOWED_TAGS
|
||||
self.attributes = ALLOWED_ATTRIBUTES
|
||||
end
|
||||
end
|
||||
@@ -1,3 +1,3 @@
|
||||
.content
|
||||
.row
|
||||
= @distributor.custom_tab.content.html_safe if @distributor.custom_tab&.content.present?
|
||||
= sanitize(@distributor.custom_tab&.content, scrubber: TrixScrubber.new)
|
||||
|
||||
Reference in New Issue
Block a user