Fixed XSS from markdown()

This commit is contained in:
chrniedz 2017-01-06 17:06:21 -06:00
parent a42240b5a6
commit 436c4fd972
4 changed files with 14 additions and 1 deletions

View file

@ -260,7 +260,7 @@ module ApplicationHelper
space_after_headers: true,
no_intra_emphasis: true
}
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, options)
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(escape_html: true), options)
markdown.render(text).html_safe
end

View file

@ -35,4 +35,8 @@ FactoryGirl.define do
end
end
end
factory :event_xss, parent: :event do
abstract { "<div id='divInjectedElement'></div>" }
end
end

View file

@ -6,4 +6,8 @@ FactoryGirl.define do
description { Faker::Lorem.paragraph }
website_link { Faker::Internet.url }
end
factory :lodging_xss, parent: :lodging do
description { "<div id='divInjectedElement'></div>" }
end
end

View file

@ -45,4 +45,9 @@ FactoryGirl.define do
end
end
end
factory :user_xss, parent: :user do
biography "<div id='divInjectedElement'></div>"
end
end