diff --git a/lib/sanitize.rb b/lib/sanitize.rb index 4dc1174..935fcaa 100644 --- a/lib/sanitize.rb +++ b/lib/sanitize.rb @@ -198,7 +198,7 @@ def to_html(node) # the original document didn't actually include a content-type meta tag. replace_meta = !@config[:elements].include?('meta') || node.xpath('/html/head/meta[@http-equiv]').none? do |meta| - meta['http-equiv'].downcase == 'content-type' + meta['http-equiv'].casecmp('content-type').zero? end end @@ -217,12 +217,14 @@ def to_html(node) end def transform_node!(node, node_whitelist) + node_name = node.name.downcase + @transformers.each do |transformer| result = transformer.call( :config => @config, :is_whitelisted => node_whitelist.include?(node), :node => node, - :node_name => node.name.downcase, + :node_name => node_name, :node_whitelist => node_whitelist ) diff --git a/lib/sanitize/transformers/clean_element.rb b/lib/sanitize/transformers/clean_element.rb index f883d52..3431be4 100644 --- a/lib/sanitize/transformers/clean_element.rb +++ b/lib/sanitize/transformers/clean_element.rb @@ -99,7 +99,7 @@ def call(env) if @protocols.include?(name) && @protocols[name].include?(attr_name) attr_protocols = @protocols[name][attr_name] - if attr.value.to_s.downcase =~ REGEX_PROTOCOL + if attr.value =~ REGEX_PROTOCOL attr.unlink unless attr_protocols.include?($1.downcase) else attr.unlink unless attr_protocols.include?(:relative) diff --git a/test/test_clean_element.rb b/test/test_clean_element.rb index 6355d78..562464c 100644 --- a/test/test_clean_element.rb +++ b/test/test_clean_element.rb @@ -402,6 +402,23 @@ s.fragment('foo