Skip to content

Commit

Permalink
Do not call #to_html in print_object for now because e.g. REXML::Text…
Browse files Browse the repository at this point in the history
… does not handle XSS protection as expected
  • Loading branch information
ChristianPeters committed Jul 24, 2011
1 parent df33fe9 commit 1beab58
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 1 addition & 3 deletions lib/active_component.rb
Expand Up @@ -142,9 +142,7 @@ def print_object(object, method = nil)
#logger = RAILS_DEFAULT_LOGGER
#logger.info "\"print_object speaking. I am about to print Object: " + object.inspect + " Method: " + method.inspect + ". Over.\""
unless method.present?
if object.respond_to? :to_html
object.to_html
elsif object.respond_to? :call
if object.respond_to? :call
begin
object.call.to_s
# Haml buffers may be provided in callable form, but have to be captured
Expand Down
3 changes: 2 additions & 1 deletion spec/active_component_spec.rb
Expand Up @@ -114,7 +114,8 @@
it "should render components" do
renderable = mock :component
html = "<div>\n Component content\n</div"
renderable.should_receive(:to_html).at_least(:once).and_return(html)
renderable.should_receive(:to_html).any_number_of_times.and_return(html)
renderable.should_receive(:to_s).any_number_of_times.and_return(html)
@comp.print_object(renderable).should == html
end

Expand Down

0 comments on commit 1beab58

Please sign in to comment.