From f17c8711f63721b8066b23b703d99e85f6e37141 Mon Sep 17 00:00:00 2001 From: Nathan Weizenbaum Date: Tue, 27 Apr 2010 18:11:05 -0700 Subject: [PATCH] [Haml] Work around the Rails on_load bug. Closes gh-142 --- lib/haml/template.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/haml/template.rb b/lib/haml/template.rb index ff1fa5c8..1f8d3790 100644 --- a/lib/haml/template.rb +++ b/lib/haml/template.rb @@ -19,7 +19,11 @@ module Haml # # @return [Boolean] Whether the XSS integration was enabled. def try_enabling_xss_integration - return false unless ActionView::Base.respond_to?(:xss_safe?) && ActionView::Base.xss_safe? + return false unless (ActionView::Base.respond_to?(:xss_safe?) && ActionView::Base.xss_safe?) || + # We check for ActiveSupport#on_load here because if we're loading Haml that way, it means: + # A) we're in Rails 3 so XSS support is always on, and + # B) we might be in Rails 3 beta 3 where the load order is broken and xss_safe? is undefined + (defined?(ActiveSupport) && Haml::Util.has?(:public_method, ActiveSupport, :on_load)) Haml::Template.options[:escape_html] = true