Skip to content

Commit

Permalink
[Haml] Work around the Rails on_load bug.
Browse files Browse the repository at this point in the history
Closes sassgh-142
  • Loading branch information
nex3 committed Apr 27, 2010
1 parent 7c9ef1c commit 099a34a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 1 addition & 2 deletions doc-src/HAML_CHANGELOG.md
Expand Up @@ -10,8 +10,7 @@
* **Support for Rails 3.0.0.beta1 has been dropped**.
Use Rails beta 2 or later instead.

* Don't improperly HTML-escape stuff like form contents
(pending the merging of [this patch to Rails](http://github.com/nex3/rails/commit/4a5ed486c326de19e83d49814a162f2246d8f73f)).
* Don't improperly HTML-escape stuff like form contents.

## 3.0.0.rc.2

Expand Down
6 changes: 5 additions & 1 deletion lib/haml/template.rb
Expand Up @@ -19,7 +19,11 @@ module Template
#
# @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

Expand Down

0 comments on commit 099a34a

Please sign in to comment.