loofah 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of loofah might be problematic. Click here for more details.

File without changes
@@ -1,5 +1,14 @@
1
1
  = Changelog
2
2
 
3
+ == 1.1.0 (2011-08-08)
4
+
5
+ Enhancements:
6
+
7
+ * Additional HTML5lib whitelist elements (from html5lib 1524:80b5efe26230).
8
+ Up to date with HTML5lib ruby code as of 1723:7ee6a0331856.
9
+ * Whitelists (which are not part of the public API) are now Sets (were previously Arrays).
10
+ * Don't explode when encountering UTF-8 URIs. (#25, #29)
11
+
3
12
  == 1.0.0 (2010-10-26)
4
13
 
5
14
  Notes:
data/Gemfile CHANGED
@@ -1 +1,19 @@
1
- gemspec
1
+ # -*- ruby -*-
2
+
3
+ # DO NOT EDIT THIS FILE. Instead, edit Rakefile, and run `rake bundler:gemfile`.
4
+
5
+ source :gemcutter
6
+
7
+ gem "nokogiri", ">=1.4.4"
8
+
9
+ gem "rake", ">=0.8", :group => [:development, :test]
10
+ gem "minitest", "~>2.2", :group => [:development, :test]
11
+ gem "rr", "~>1.0", :group => [:development, :test]
12
+ gem "json", ">=0", :group => [:development, :test]
13
+ gem "hoe-gemspec", ">=0", :group => [:development, :test]
14
+ gem "hoe-debugging", ">=0", :group => [:development, :test]
15
+ gem "hoe-bundler", ">=0", :group => [:development, :test]
16
+ gem "hoe-git", ">=0", :group => [:development, :test]
17
+ gem "hoe", ">=2.9.4", :group => [:development, :test]
18
+
19
+ # vim: syntax=ruby
@@ -21,6 +21,7 @@ lib/loofah/scrubber.rb
21
21
  lib/loofah/scrubbers.rb
22
22
  lib/loofah/xml/document.rb
23
23
  lib/loofah/xml/document_fragment.rb
24
+ test/assets/testdata_sanitizer_tests1.dat
24
25
  test/helper.rb
25
26
  test/html5/test_sanitizer.rb
26
27
  test/integration/test_ad_hoc.rb
@@ -29,6 +30,7 @@ test/integration/test_html.rb
29
30
  test/integration/test_scrubbers.rb
30
31
  test/integration/test_xml.rb
31
32
  test/unit/test_api.rb
33
+ test/unit/test_encoding.rb
32
34
  test/unit/test_helpers.rb
33
35
  test/unit/test_scrubber.rb
34
36
  test/unit/test_scrubbers.rb
@@ -291,7 +291,7 @@ name that nobody could spell properly.
291
291
 
292
292
  The MIT License
293
293
 
294
- Copyright (c) 2009, 2010 by Mike Dalessio, Bryan Helmkamp
294
+ Copyright (c) 2009, 2010, 2011 by Mike Dalessio, Bryan Helmkamp
295
295
 
296
296
  Permission is hereby granted, free of charge, to any person obtaining a copy
297
297
  of this software and associated documentation files (the "Software"), to deal
data/Rakefile CHANGED
@@ -4,6 +4,8 @@ require 'hoe'
4
4
 
5
5
  Hoe.plugin :git
6
6
  Hoe.plugin :gemspec
7
+ Hoe.plugin :bundler
8
+ Hoe.plugin :debugging
7
9
 
8
10
  Hoe.spec "loofah" do
9
11
  developer "Mike Dalessio", "mike.dalessio@gmail.com"
@@ -13,10 +15,16 @@ Hoe.spec "loofah" do
13
15
  self.history_file = "CHANGELOG.rdoc"
14
16
  self.readme_file = "README.rdoc"
15
17
 
16
- extra_deps << ["nokogiri", ">=1.3.3"]
17
- extra_dev_deps << ["mocha", ">=0.9"]
18
- extra_dev_deps << ["shoulda", ">=2.10"]
18
+ extra_deps << ["nokogiri", ">=1.4.4"]
19
+
19
20
  extra_dev_deps << ["rake", ">=0.8"]
21
+ extra_dev_deps << ["minitest", "~>2.2"]
22
+ extra_dev_deps << ["rr", "~>1.0"]
23
+ extra_dev_deps << ["json", ">=0"]
24
+ extra_dev_deps << ["hoe-gemspec", ">=0"]
25
+ extra_dev_deps << ["hoe-debugging", ">=0"]
26
+ extra_dev_deps << ["hoe-bundler", ">=0"]
27
+ extra_dev_deps << ["hoe-git", ">=0"]
20
28
  end
21
29
 
22
30
  task :gemspec do
@@ -29,10 +29,7 @@ require 'loofah/helpers'
29
29
  #
30
30
  module Loofah
31
31
  # The version of Loofah you are using
32
- VERSION = '1.0.0'
33
-
34
- # The minimum required version of Nokogiri
35
- REQUIRED_NOKOGIRI_VERSION = '1.3.3'
32
+ VERSION = '1.1.0'
36
33
 
37
34
  class << self
38
35
  # Shortcut for Loofah::HTML::Document.parse
@@ -81,7 +78,3 @@ module Loofah
81
78
 
82
79
  end
83
80
  end
84
-
85
- if Nokogiri::VERSION < Loofah::REQUIRED_NOKOGIRI_VERSION
86
- raise RuntimeError, "Loofah requires Nokogiri #{Loofah::REQUIRED_NOKOGIRI_VERSION} or later (currently #{Nokogiri::VERSION})"
87
- end
@@ -1,19 +1,17 @@
1
+ require 'set'
2
+
1
3
  module Loofah
2
4
  module Elements
3
5
  # Block elements in HTML4
4
- STRICT_BLOCK_LEVEL = %w[address blockquote center dir div dl
6
+ STRICT_BLOCK_LEVEL = Set.new %w[address blockquote center dir div dl
5
7
  fieldset form h1 h2 h3 h4 h5 h6 hr isindex menu noframes
6
8
  noscript ol p pre table ul]
7
9
 
8
10
  # The following elements may also be considered block-level elements since they may contain block-level elements
9
- LOOSE_BLOCK_LEVEL = %w[dd dt frameset li tbody td tfoot th thead tr]
11
+ LOOSE_BLOCK_LEVEL = Set.new %w[dd dt frameset li tbody td tfoot th thead tr]
10
12
 
11
13
  BLOCK_LEVEL = STRICT_BLOCK_LEVEL + LOOSE_BLOCK_LEVEL
12
14
  end
13
15
 
14
- module HashedElements
15
- include Loofah::MetaHelpers::HashifiedConstants(Elements)
16
- end
16
+ ::Loofah::MetaHelpers.add_downcased_set_members_to_all_set_constants ::Loofah::Elements
17
17
  end
18
-
19
-
@@ -15,7 +15,9 @@ module Loofah
15
15
  # parse a fragment.
16
16
  #
17
17
  def parse tags
18
- self.new(Loofah::HTML::Document.new, tags)
18
+ doc = Loofah::HTML::Document.new
19
+ doc.encoding = tags.encoding.name if tags.respond_to?(:encoding)
20
+ self.new(doc, tags)
19
21
  end
20
22
  end
21
23
 
@@ -4,38 +4,53 @@ module Loofah
4
4
  module HTML5 # :nodoc:
5
5
  module Scrub
6
6
 
7
+ CONTROL_CHARACTERS = if RUBY_VERSION =~ /^1\.8/
8
+ /`|[\000-\040\177\s]+|\302[\200-\240]/
9
+ else
10
+ /[`\u0000-\u0020\u007F\s\u0080-\u0101]/
11
+ end
12
+
7
13
  class << self
8
14
 
15
+ def allowed_element? element_name
16
+ ::Loofah::HTML5::WhiteList::ALLOWED_ELEMENTS_WITH_LIBXML2.include? element_name
17
+ end
18
+
9
19
  # alternative implementation of the html5lib attribute scrubbing algorithm
10
- def scrub_attributes(node)
20
+ def scrub_attributes node
11
21
  node.attribute_nodes.each do |attr_node|
12
22
  attr_name = if attr_node.namespace
13
23
  "#{attr_node.namespace.prefix}:#{attr_node.node_name}"
14
24
  else
15
25
  attr_node.node_name
16
26
  end
17
- attr_node.remove unless HashedWhiteList::ALLOWED_ATTRIBUTES[attr_name]
18
- if HashedWhiteList::ATTR_VAL_IS_URI[attr_name]
27
+ unless WhiteList::ALLOWED_ATTRIBUTES.include?(attr_name)
28
+ attr_node.remove
29
+ next
30
+ end
31
+ if WhiteList::ATTR_VAL_IS_URI.include?(attr_name)
19
32
  # this block lifted nearly verbatim from HTML5 sanitization
20
- val_unescaped = CGI.unescapeHTML(attr_node.value).gsub(/`|[\000-\040\177\s]+|\302[\200-\240]/,'').downcase
21
- if val_unescaped =~ /^[a-z0-9][-+.a-z0-9]*:/ and HashedWhiteList::ALLOWED_PROTOCOLS[val_unescaped.split(':')[0]].nil?
33
+ val_unescaped = CGI.unescapeHTML(attr_node.value).gsub(CONTROL_CHARACTERS,'').downcase
34
+ if val_unescaped =~ /^[a-z0-9][-+.a-z0-9]*:/ && ! WhiteList::ALLOWED_PROTOCOLS.include?(val_unescaped.split(':')[0])
22
35
  attr_node.remove
36
+ next
23
37
  end
24
38
  end
25
- if HashedWhiteList::SVG_ATTR_VAL_ALLOWS_REF[attr_name]
39
+ if WhiteList::SVG_ATTR_VAL_ALLOWS_REF.include?(attr_name)
26
40
  attr_node.value = attr_node.value.gsub(/url\s*\(\s*[^#\s][^)]+?\)/m, ' ') if attr_node.value
27
41
  end
28
- if HashedWhiteList::SVG_ALLOW_LOCAL_HREF[node.name] && attr_name == 'xlink:href' && attr_node.value =~ /^\s*[^#\s].*/m
42
+ if WhiteList::SVG_ALLOW_LOCAL_HREF.include?(node.name) && attr_name == 'xlink:href' && attr_node.value =~ /^\s*[^#\s].*/m
29
43
  attr_node.remove
44
+ next
30
45
  end
31
46
  end
32
47
  if node.attributes['style']
33
- node['style'] = scrub_css(node.attributes['style'])
48
+ node['style'] = scrub_css node.attributes['style']
34
49
  end
35
50
  end
36
51
 
37
52
  # lifted nearly verbatim from html5lib
38
- def scrub_css(style)
53
+ def scrub_css style
39
54
  # disallow urls
40
55
  style = style.to_s.gsub(/url\s*\(\s*[^\s)]+?\s*\)\s*/, ' ')
41
56
 
@@ -47,14 +62,14 @@ module Loofah
47
62
  style.scan(/([-\w]+)\s*:\s*([^:;]*)/) do |prop, val|
48
63
  next if val.empty?
49
64
  prop.downcase!
50
- if HashedWhiteList::ALLOWED_CSS_PROPERTIES[prop]
65
+ if WhiteList::ALLOWED_CSS_PROPERTIES.include?(prop)
51
66
  clean << "#{prop}: #{val};"
52
67
  elsif %w[background border margin padding].include?(prop.split('-')[0])
53
68
  clean << "#{prop}: #{val};" unless val.split().any? do |keyword|
54
- HashedWhiteList::ALLOWED_CSS_KEYWORDS[keyword].nil? and
69
+ WhiteList::ALLOWED_CSS_KEYWORDS.include?(keyword) &&
55
70
  keyword !~ /^(#[0-9a-f]+|rgb\(\d+%?,\d*%?,?\d*%?\)?|\d{0,2}\.?\d{0,2}(cm|em|ex|in|mm|pc|pt|px|%|,|\))?)$/
56
71
  end
57
- elsif HashedWhiteList::ALLOWED_SVG_PROPERTIES[prop]
72
+ elsif WhiteList::ALLOWED_SVG_PROPERTIES.include?(prop)
58
73
  clean << "#{prop}: #{val};"
59
74
  end
60
75
  end
@@ -67,4 +82,3 @@ module Loofah
67
82
  end
68
83
  end
69
84
  end
70
-
@@ -1,3 +1,5 @@
1
+ require 'set'
2
+
1
3
  module Loofah
2
4
  module HTML5 # :nodoc:
3
5
  #
@@ -43,53 +45,59 @@ module Loofah
43
45
  #
44
46
  # </html5_license>
45
47
  module WhiteList
46
- ACCEPTABLE_ELEMENTS = %w[a abbr acronym address area b big blockquote br
48
+ ACCEPTABLE_ELEMENTS = Set.new %w[a abbr acronym address area audio b big blockquote br
47
49
  button caption center cite code col colgroup dd del dfn dir div dl dt
48
50
  em fieldset font form h1 h2 h3 h4 h5 h6 hr i img input ins kbd label
49
51
  legend li map menu ol optgroup option p pre q s samp select small span
50
52
  strike strong sub sup table tbody td textarea tfoot th thead tr tt u
51
- ul var]
53
+ ul var video]
52
54
 
53
- MATHML_ELEMENTS = %w[annotation annotation-xml maction math merror mfrac
55
+ MATHML_ELEMENTS = Set.new %w[annotation annotation-xml maction math merror mfrac
54
56
  mfenced mi mmultiscripts mn mo mover mpadded mphantom mprescripts mroot mrow
55
57
  mspace msqrt mstyle msub msubsup msup mtable mtd mtext mtr munder
56
58
  munderover none semantics]
57
59
 
58
- SVG_ELEMENTS = %w[a animate animateColor animateMotion animateTransform
59
- circle defs desc ellipse font-face font-face-name font-face-src foreignObject
60
- g glyph hkern linearGradient line marker metadata missing-glyph
60
+ SVG_ELEMENTS = Set.new %w[a animate animateColor animateMotion animateTransform
61
+ circle clipPath defs desc ellipse feGaussianBlur filter font-face
62
+ font-face-name font-face-src foreignObject
63
+ g glyph hkern linearGradient line marker mask metadata missing-glyph
61
64
  mpath path polygon polyline radialGradient rect set stop svg switch
62
- text title tspan use]
65
+ text textPath title tspan use]
63
66
 
64
- ACCEPTABLE_ATTRIBUTES = %w[abbr accept accept-charset accesskey action
67
+ ACCEPTABLE_ATTRIBUTES = Set.new %w[abbr accept accept-charset accesskey action
65
68
  align alt axis border cellpadding cellspacing char charoff charset
66
69
  checked cite class clear cols colspan color compact coords datetime
67
70
  dir disabled enctype for frame headers height href hreflang hspace id
68
- ismap label lang longdesc maxlength media method multiple name nohref
69
- noshade nowrap prompt readonly rel rev rows rowspan rules scope
71
+ ismap label lang longdesc loop loopcount loopend loopstart
72
+ maxlength media method multiple name nohref
73
+ noshade nowrap poster prompt readonly rel rev rows rowspan rules scope
70
74
  selected shape size span src start style summary tabindex target title
71
75
  type usemap valign value vspace width xml:lang]
72
76
 
73
- MATHML_ATTRIBUTES = %w[actiontype align close columnalign columnalign
77
+ MATHML_ATTRIBUTES = Set.new %w[actiontype align close
74
78
  columnalign columnlines columnspacing columnspan depth display
75
79
  displaystyle encoding equalcolumns equalrows fence fontstyle fontweight
76
80
  frame height linethickness lspace mathbackground mathcolor mathvariant
77
- mathvariant maxsize minsize open other rowalign rowalign rowalign rowlines
81
+ maxsize minsize open other rowalign rowlines
78
82
  rowspacing rowspan rspace scriptlevel selection separator separators
79
- stretchy width width xlink:href xlink:show xlink:type xmlns xmlns:xlink]
83
+ stretchy width xlink:href xlink:show xlink:type xmlns xmlns:xlink]
80
84
 
81
- SVG_ATTRIBUTES = %w[accent-height accumulate additive alphabetic
85
+ SVG_ATTRIBUTES = Set.new %w[accent-height accumulate additive alphabetic
82
86
  arabic-form ascent attributeName attributeType baseProfile bbox begin
83
- by calcMode cap-height class color color-rendering content cx cy d dx
84
- dy descent display dur end fill fill-opacity fill-rule font-family
87
+ by calcMode cap-height class clip-path clip-rule color
88
+ color-interpolation-filters color-rendering content cx cy d dx
89
+ dy descent display dur end fill fill-opacity fill-rule
90
+ filterRes filterUnits font-family
85
91
  font-size font-stretch font-style font-variant font-weight from fx fy g1
86
92
  g2 glyph-name gradientUnits hanging height horiz-adv-x horiz-origin-x id
87
93
  ideographic k keyPoints keySplines keyTimes lang marker-end
88
94
  marker-mid marker-start markerHeight markerUnits markerWidth
89
- mathematical max min name offset opacity orient origin
90
- overline-position overline-thickness panose-1 path pathLength points
91
- preserveAspectRatio r refX refY repeatCount repeatDur
92
- requiredExtensions requiredFeatures restart rotate rx ry slope stemh
95
+ maskContentUnits maskUnits mathematical max method min name offset opacity orient origin
96
+ overline-position overline-thickness panose-1 path pathLength
97
+ patternContentUnits patternTransform patternUnits points
98
+ preserveAspectRatio primitiveUnits r refX refY repeatCount repeatDur
99
+ requiredExtensions requiredFeatures restart rotate rx ry slope spacing
100
+ startOffset stdDeviation stemh
93
101
  stemv stop-color stop-opacity strikethrough-position
94
102
  strikethrough-thickness stroke stroke-dasharray stroke-dashoffset
95
103
  stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity
@@ -100,16 +108,16 @@ module Loofah
100
108
  xlink:show xlink:title xlink:type xml:base xml:lang xml:space xmlns
101
109
  xmlns:xlink y y1 y2 zoomAndPan]
102
110
 
103
- ATTR_VAL_IS_URI = %w[href src cite action longdesc xlink:href xml:base]
111
+ ATTR_VAL_IS_URI = Set.new %w[href src cite action longdesc xlink:href xml:base]
104
112
 
105
- SVG_ATTR_VAL_ALLOWS_REF = %w[clip-path color-profile cursor fill
113
+ SVG_ATTR_VAL_ALLOWS_REF = Set.new %w[clip-path color-profile cursor fill
106
114
  filter marker marker-start marker-mid marker-end mask stroke]
107
115
 
108
- SVG_ALLOW_LOCAL_HREF = %w[altGlyph animate animateColor animateMotion
116
+ SVG_ALLOW_LOCAL_HREF = Set.new %w[altGlyph animate animateColor animateMotion
109
117
  animateTransform cursor feImage filter linearGradient pattern
110
118
  radialGradient textpath tref set use]
111
119
 
112
- ACCEPTABLE_CSS_PROPERTIES = %w[azimuth background-color
120
+ ACCEPTABLE_CSS_PROPERTIES = Set.new %w[azimuth background-color
113
121
  border-bottom-color border-collapse border-color border-left-color
114
122
  border-right-color border-top-color clear color cursor direction
115
123
  display elevation float font font-family font-size font-style
@@ -119,16 +127,16 @@ module Loofah
119
127
  text-align text-decoration text-indent unicode-bidi vertical-align
120
128
  voice-family volume white-space width]
121
129
 
122
- ACCEPTABLE_CSS_KEYWORDS = %w[auto aqua black block blue bold both bottom
130
+ ACCEPTABLE_CSS_KEYWORDS = Set.new %w[auto aqua black block blue bold both bottom
123
131
  brown center collapse dashed dotted fuchsia gray green !important
124
132
  italic left lime maroon medium none navy normal nowrap olive pointer
125
133
  purple red right solid silver teal top transparent underline white
126
134
  yellow]
127
135
 
128
- ACCEPTABLE_SVG_PROPERTIES = %w[fill fill-opacity fill-rule stroke
136
+ ACCEPTABLE_SVG_PROPERTIES = Set.new %w[fill fill-opacity fill-rule stroke
129
137
  stroke-width stroke-linecap stroke-linejoin stroke-opacity]
130
138
 
131
- ACCEPTABLE_PROTOCOLS = %w[ed2k ftp http https irc mailto news gopher nntp
139
+ ACCEPTABLE_PROTOCOLS = Set.new %w[ed2k ftp http https irc mailto news gopher nntp
132
140
  telnet webcal xmpp callto feed urn aim rsync tag ssh sftp rtsp afs]
133
141
 
134
142
  # subclasses may define their own versions of these constants
@@ -139,7 +147,7 @@ module Loofah
139
147
  ALLOWED_SVG_PROPERTIES = ACCEPTABLE_SVG_PROPERTIES
140
148
  ALLOWED_PROTOCOLS = ACCEPTABLE_PROTOCOLS
141
149
 
142
- VOID_ELEMENTS = %w[
150
+ VOID_ELEMENTS = Set.new %w[
143
151
  base
144
152
  link
145
153
  meta
@@ -154,15 +162,10 @@ module Loofah
154
162
  ]
155
163
 
156
164
  # additional tags we should consider safe since we have libxml2 fixing up our documents.
157
- TAGS_SAFE_WITH_LIBXML2 = %w[html head body]
165
+ TAGS_SAFE_WITH_LIBXML2 = Set.new %w[html head body]
158
166
  ALLOWED_ELEMENTS_WITH_LIBXML2 = ALLOWED_ELEMENTS + TAGS_SAFE_WITH_LIBXML2
159
167
  end
160
168
 
161
- #
162
- # The HTML5lib whitelist arrays, transformed into hashes for faster lookup.
163
- #
164
- module HashedWhiteList
165
- include Loofah::MetaHelpers::HashifiedConstants(WhiteList)
166
- end
169
+ ::Loofah::MetaHelpers.add_downcased_set_members_to_all_set_constants ::Loofah::HTML5::WhiteList
167
170
  end
168
171
  end
@@ -41,7 +41,7 @@ module Loofah
41
41
  when Nokogiri::XML::Document
42
42
  scrubber.traverse(root) if root
43
43
  when Nokogiri::XML::DocumentFragment
44
- children.each { |node| node.scrub!(scrubber) } # TODO: children.scrub! once Nokogiri 1.4.2 is out
44
+ children.scrub! scrubber
45
45
  else
46
46
  scrubber.traverse(self)
47
47
  end
@@ -1,15 +1,13 @@
1
1
  module Loofah
2
2
  module MetaHelpers
3
- def self.HashifiedConstants(orig_module)
4
- hashed_module = Module.new
5
- orig_module.constants.each do |constant|
6
- next unless orig_module.module_eval("#{constant}").is_a?(Array)
7
- hashed_module.module_eval <<-CODE
8
- #{constant} = {}
9
- #{orig_module.name}::#{constant}.each { |c| #{constant}[c] = true ; #{constant}[c.downcase] = true }
10
- CODE
3
+ def self.add_downcased_set_members_to_all_set_constants mojule
4
+ mojule.constants.each do |constant_sym|
5
+ constant = mojule.const_get constant_sym
6
+ next unless Set === constant
7
+ constant.dup.each do |member|
8
+ constant.add member.downcase
9
+ end
11
10
  end
12
- hashed_module
13
11
  end
14
12
  end
15
13
  end
@@ -91,7 +91,7 @@ module Loofah
91
91
  def html5lib_sanitize(node)
92
92
  case node.type
93
93
  when Nokogiri::XML::Node::ELEMENT_NODE
94
- if HTML5::HashedWhiteList::ALLOWED_ELEMENTS_WITH_LIBXML2[node.name]
94
+ if HTML5::Scrub.allowed_element? node.name
95
95
  HTML5::Scrub.scrub_attributes node
96
96
  return Scrubber::CONTINUE
97
97
  end
@@ -75,7 +75,7 @@ module Loofah
75
75
 
76
76
  def scrub(node)
77
77
  return CONTINUE if html5lib_sanitize(node) == CONTINUE
78
- node.before node.inner_html
78
+ node.before node.children
79
79
  node.remove
80
80
  end
81
81
  end
@@ -117,8 +117,7 @@ module Loofah
117
117
 
118
118
  def scrub(node)
119
119
  return CONTINUE if html5lib_sanitize(node) == CONTINUE
120
- replacement_killer = Nokogiri::XML::Text.new(node.to_s, node.document)
121
- node.add_next_sibling replacement_killer
120
+ node.add_next_sibling Nokogiri::XML::Text.new(node.to_s, node.document)
122
121
  node.remove
123
122
  return STOP
124
123
  end
@@ -150,7 +149,7 @@ module Loofah
150
149
  def scrub(node)
151
150
  case node.type
152
151
  when Nokogiri::XML::Node::ELEMENT_NODE
153
- if HTML5::HashedWhiteList::ALLOWED_ELEMENTS_WITH_LIBXML2[node.name]
152
+ if HTML5::Scrub.allowed_element? node.name
154
153
  node.attributes.each { |attr| node.remove_attribute(attr.first) }
155
154
  return CONTINUE if node.namespaces.empty?
156
155
  end
@@ -190,9 +189,8 @@ module Loofah
190
189
  end
191
190
 
192
191
  def scrub(node)
193
- return CONTINUE unless Loofah::HashedElements::BLOCK_LEVEL[node.name]
194
- replacement_killer = Nokogiri::XML::Text.new("\n#{node.content}\n", node.document)
195
- node.add_next_sibling replacement_killer
192
+ return CONTINUE unless Loofah::Elements::BLOCK_LEVEL.include?(node.name)
193
+ node.add_next_sibling Nokogiri::XML::Text.new("\n#{node.content}\n", node.document)
196
194
  node.remove
197
195
  end
198
196
  end