Skip to content

Commit

Permalink
Clean elements before cleaning styles
Browse files Browse the repository at this point in the history
So CPU will no longer be wasted cleaning style="" attributes on non-permitted elements, nor cleaning <style> contents if <style> elements are not permitted.
  • Loading branch information
rafbm committed May 16, 2018
1 parent acc7e64 commit fc82e96
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/sanitize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def initialize(config = {})

# Default transformers always run at the end of the chain, after any custom
# transformers.
@transformers << Transformers::CleanElement.new(@config)
@transformers << Transformers::CleanComment unless @config[:allow_comments]

if @config[:elements].include?('style')
Expand All @@ -95,8 +96,7 @@ def initialize(config = {})

@transformers <<
Transformers::CleanDoctype <<
Transformers::CleanCDATA <<
Transformers::CleanElement.new(@config)
Transformers::CleanCDATA
end

# Returns a sanitized copy of the given _html_ document.
Expand Down

0 comments on commit fc82e96

Please sign in to comment.