Skip to content

Commit

Permalink
Sanitize content in section and title presenters
Browse files Browse the repository at this point in the history
  • Loading branch information
bricesanchez authored and Brice Sanchez committed Mar 4, 2016
1 parent 519b7ed commit 8d27789
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions pages/app/presenters/refinery/pages/section_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module Pages
# Sections may be hidden, in which case they wont display at all.
class SectionPresenter
include ActionView::Helpers::TagHelper
include ActionView::Helpers::SanitizeHelper

def initialize(initial_hash = {})
initial_hash.map do |key, value|
Expand Down Expand Up @@ -62,6 +63,10 @@ def html_from_fallback(can_use_fallback)
attr_writer :id, :fallback_html, :hidden

def wrap_content_in_tag(content)
content = sanitize(content,
tags: Loofah::HTML5::WhiteList::ALLOWED_ELEMENTS,
attributes: Loofah::HTML5::WhiteList::ALLOWED_ATTRIBUTES
)
content_tag(:section, content_tag(:div, content, :class => 'inner'), :id => id)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class TitleSectionPresenter < SectionPresenter
private

def wrap_content_in_tag(content)
content_tag(:h1, content, :id => id)
content_tag(:h1, sanitize(content), :id => id)
end
end
end
Expand Down

0 comments on commit 8d27789

Please sign in to comment.