Skip to content

Commit

Permalink
DisplayHelper should not sanitize its input
Browse files Browse the repository at this point in the history
  • Loading branch information
faucct committed Dec 28, 2017
1 parent ac4768e commit 6a2f8f3
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/active_admin/view_helpers/display_helper.rb
Expand Up @@ -66,7 +66,7 @@ def find_value(resource, attr)
def pretty_format(object)
case object
when String, Numeric, Symbol, Arbre::Element
sanitize(object.to_s)
object.to_s
when Date, Time
I18n.localize object, format: active_admin_application.localize_format
else
Expand Down
10 changes: 1 addition & 9 deletions spec/unit/pretty_format_spec.rb
Expand Up @@ -8,20 +8,12 @@ def method_missing(*args, &block)
mock_action_view.send *args, &block
end

['hello', 23, 5.67, 10**30, :foo].each do |obj|
['hello', 23, 5.67, 10**30, :foo, Arbre::Element.new.br].each do |obj|
it "should call `to_s` on #{obj.class}s" do
expect(pretty_format(obj)).to eq obj.to_s
end
end

it "normalizes Arbre elements" do
expect(pretty_format(Arbre::Element.new.br)).to eq("<br>\n")
end

it "sanitizes Arbre elements" do
expect(pretty_format(Arbre::Element.new.script('alert("foo");'))).to eq("alert(&amp;quot;foo&amp;quot;);\n")
end

shared_examples_for 'a time-ish object' do |t|
it "formats it with the default long format" do
expect(pretty_format(t)).to eq "February 28, 1985 20:15"
Expand Down
1 change: 0 additions & 1 deletion spec/unit/view_helpers/display_helper_spec.rb
Expand Up @@ -10,7 +10,6 @@
include ActiveAdmin::ViewHelpers::DisplayHelper
include MethodOrProcHelper
include ActionView::Helpers::UrlHelper
include ActionView::Helpers::SanitizeHelper
include ActionView::Helpers::TranslationHelper
include ActionView::Helpers::SanitizeHelper

Expand Down

0 comments on commit 6a2f8f3

Please sign in to comment.