Skip to content

Commit

Permalink
Merge pull request #2 from michaelglass/master
Browse files Browse the repository at this point in the history
When a config block is not provided, inherit ActionView defaults
  • Loading branch information
vjt committed Mar 3, 2014
2 parents 8693118 + b5c9bc3 commit a0640cc
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/sanitize/rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,20 @@ def configure(config)

# Returns a memoized instance of the Engine with the
# configuration passed to the +configure+ method or with
# the Gem default configuration.
# the ActionView's default config
#
def cleaner
@sanitizer ||= ::Sanitize.new(@@config || {})
@@config ||= begin
{
:elements => ::ActionView::Base.sanitized_allowed_tags.to_a,
:attributes => { :all => ::ActionView::Base.sanitized_allowed_attributes.to_a},
:protocols => { :all => ::ActionView::Base.sanitized_allowed_protocols.to_a }
}
rescue
warn "ActionView not available, falling back to Sanitize's BASIC config"
::Sanitize::Config::BASIC
end
@sanitizer ||= ::Sanitize.new(@@config)
end

# Returns a copy of the given `string` after sanitizing it
Expand Down

0 comments on commit a0640cc

Please sign in to comment.