"
@@ -178,7 +178,6 @@ def test_should_disallow_other_uri_mediatypes
check_sanitization(input, output, output, output)
end
-
HTML5::SafeList::SVG_ALLOW_LOCAL_HREF.each do |tag_name|
next unless HTML5::SafeList::ALLOWED_ELEMENTS.include?(tag_name)
define_method "test_#{tag_name}_should_allow_local_href" do
@@ -228,12 +227,12 @@ def test_figure_element_is_valid
# check_sanitization(input, output, output, output)
# end
-# This affects only NS4. Is it worth fixing?
-# def test_javascript_includes
-# input = %(
foo
)
-# output = "
foo
"
-# check_sanitization(input, output, output, output)
-# end
+ # This affects only NS4. Is it worth fixing?
+ # def test_javascript_includes
+ # input = %(
foo
)
+ # output = "
foo
"
+ # check_sanitization(input, output, output, output)
+ # end
##
## these tests primarily test the parser logic, not the sanitizer
@@ -241,15 +240,15 @@ def test_figure_element_is_valid
## libxml2 here, so let's rely on the unit tests above to take care
## of our valid elements and attributes.
##
- require 'json'
- Dir[File.join(File.dirname(__FILE__), '..', 'assets', 'testdata_sanitizer_tests1.dat')].each do |filename|
+ require "json"
+ Dir[File.join(File.dirname(__FILE__), "..", "assets", "testdata_sanitizer_tests1.dat")].each do |filename|
JSON::parse(open(filename).read).each do |test|
- it "testdata sanitizer #{test['name']}" do
+ it "testdata sanitizer #{test["name"]}" do
check_sanitization(
- test['input'],
- test['output'],
- test['xhtml'] || test['output'],
- test['rexml'] || test['output']
+ test["input"],
+ test["output"],
+ test["xhtml"] || test["output"],
+ test["rexml"] || test["output"]
)
end
end
@@ -338,7 +337,6 @@ def test_css_max_width
assert_match %r/max-width/, sane.inner_html
end
-
def test_issue_90_slow_regex
skip("timing tests are hard to make pass and have little regression-testing value")
diff --git a/test/integration/test_html.rb b/test/integration/test_html.rb
index b00d5ac8..ab9746eb 100644
--- a/test/integration/test_html.rb
+++ b/test/integration/test_html.rb
@@ -35,10 +35,10 @@ class IntegrationTestHtml < Loofah::TestCase
end
end
- context 'with an `encoding` arg' do
+ context "with an `encoding` arg" do
it "sets the parent document's encoding to accordingly" do
- html = Loofah.fragment "
"
- ENTITY_TEXT = %Q(this is < that "&" the other > boo\'yaw00t)
+ ENTITY_FRAGMENT = "
this is < that "&" the other > boo'ya
w00t
"
+ ENTITY_TEXT = %Q(this is < that "&" the other > boo\'yaw00t)
- ENTITY_HACK_ATTACK = "
Hack attack!
<script>alert('evil')</script>
"
+ ENTITY_HACK_ATTACK = "
Hack attack!
<script>alert('evil')</script>
"
ENTITY_HACK_ATTACK_TEXT_SCRUB = "Hack attack!<script>alert('evil')</script>"
ENTITY_HACK_ATTACK_TEXT_SCRUB_UNESC = "Hack attack!"
@@ -39,7 +38,7 @@ class IntegrationTestScrubbers < Loofah::TestCase
doc = Loofah::HTML::Document.parse "#{INVALID_FRAGMENT}"
result = doc.scrub! :escape
- assert_equal INVALID_ESCAPED, doc.xpath('/html/body').inner_html
+ assert_equal INVALID_ESCAPED, doc.xpath("/html/body").inner_html
assert_equal doc, result
end
end
@@ -49,7 +48,7 @@ class IntegrationTestScrubbers < Loofah::TestCase
doc = Loofah::HTML::Document.parse "#{INVALID_FRAGMENT}"
result = doc.scrub! :prune
- assert_equal INVALID_PRUNED, doc.xpath('/html/body').inner_html
+ assert_equal INVALID_PRUNED, doc.xpath("/html/body").inner_html
assert_equal doc, result
end
end
@@ -59,7 +58,7 @@ class IntegrationTestScrubbers < Loofah::TestCase
doc = Loofah::HTML::Document.parse "#{INVALID_FRAGMENT}"
result = doc.scrub! :strip
- assert_equal INVALID_STRIPPED, doc.xpath('/html/body').inner_html
+ assert_equal INVALID_STRIPPED, doc.xpath("/html/body").inner_html
assert_equal doc, result
end
end
@@ -69,7 +68,7 @@ class IntegrationTestScrubbers < Loofah::TestCase
doc = Loofah::HTML::Document.parse "#{WHITEWASH_FRAGMENT}"
result = doc.scrub! :whitewash
- assert_equal WHITEWASH_RESULT, doc.xpath('/html/body').inner_html
+ assert_equal WHITEWASH_RESULT, doc.xpath("/html/body").inner_html
assert_equal doc, result
end
end
@@ -79,7 +78,7 @@ class IntegrationTestScrubbers < Loofah::TestCase
doc = Loofah::HTML::Document.parse "#{NOFOLLOW_FRAGMENT}"
result = doc.scrub! :nofollow
- assert_equal NOFOLLOW_RESULT, doc.xpath('/html/body').inner_html
+ assert_equal NOFOLLOW_RESULT, doc.xpath("/html/body").inner_html
assert_equal doc, result
end
end
@@ -177,7 +176,7 @@ class IntegrationTestScrubbers < Loofah::TestCase
EOHTML
node = xml.at_css "div.scrub"
node.scrub!(:prune)
- assert_match %r/I should remain/, xml.to_s
+ assert_match %r/I should remain/, xml.to_s
refute_match %r/I should be removed/, xml.to_s
end
end
@@ -202,8 +201,8 @@ class IntegrationTestScrubbers < Loofah::TestCase
node_set = xml.css "div.scrub"
assert_equal 2, node_set.length
node_set.scrub!(:prune)
- assert_match %r/I should remain/, xml.to_s
- refute_match %r/I should be removed/, xml.to_s
+ assert_match %r/I should remain/, xml.to_s
+ refute_match %r/I should be removed/, xml.to_s
refute_match %r/I should also be removed/, xml.to_s
end
end
@@ -253,7 +252,6 @@ class IntegrationTestScrubbers < Loofah::TestCase
end
context ":nofollow" do
-
context "for a hyperlink that does not have a rel attribute" do
it "add a 'nofollow' attribute to hyperlinks" do
doc = Loofah::HTML::DocumentFragment.parse "
#{NOFOLLOW_FRAGMENT}
"
@@ -266,15 +264,13 @@ class IntegrationTestScrubbers < Loofah::TestCase
context "for a hyperlink that does have a rel attribute" do
it "appends nofollow to rel attribute" do
- doc = Loofah::HTML::DocumentFragment.parse "