Skip to content
This repository has been archived by the owner on Jan 5, 2019. It is now read-only.

Commit

Permalink
Customize tag and attribute sanitization
Browse files Browse the repository at this point in the history
Fixes #6
  • Loading branch information
javan committed Oct 3, 2018
1 parent aa1d463 commit 598ef2e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/helpers/action_text/content_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ def render_action_text_content(content)
end.chomp
end

content.to_html
sanitize content.to_html, tags: ActionText::ALLOWED_TAGS, attributes: ActionText::ALLOWED_ATTRIBUTES
end
end

SANITIZER = Rails::Html::Sanitizer.white_list_sanitizer
ALLOWED_TAGS = SANITIZER.allowed_tags + [ ActionText::Attachment::TAG_NAME, "figure", "figcaption" ]
ALLOWED_ATTRIBUTES = SANITIZER.allowed_attributes + ActionText::Attachment::ATTRIBUTES
end
2 changes: 1 addition & 1 deletion app/views/action_text/content/_layout.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div class="trix-content">
<%= sanitize render_action_text_content(content) %>
<%= render_action_text_content(content) %>
</div>

0 comments on commit 598ef2e

Please sign in to comment.