Skip to content

Commit a5bd819

Browse files
committed
rufo formatting
1 parent 1bdf276 commit a5bd819

File tree

2 files changed

+18
-21
lines changed

2 files changed

+18
-21
lines changed

lib/loofah/html5/safelist.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'set'
1+
require "set"
22

33
module Loofah
44
module HTML5 # :nodoc:
@@ -45,7 +45,6 @@ module HTML5 # :nodoc:
4545
#
4646
# </html5_license>
4747
module SafeList
48-
4948
ACCEPTABLE_ELEMENTS = Set.new([
5049
"a",
5150
"abbr",

test/integration/test_ad_hoc.rb

+17-19
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
require "helper"
22

33
class IntegrationTestAdHoc < Loofah::TestCase
4-
54
context "blank input string" do
65
context "fragment" do
76
it "return a blank string" do
@@ -33,9 +32,9 @@ def test_removal_of_illegal_attribute
3332
html = "<p class=bar foo=bar abbr=bar />"
3433
sane = Nokogiri::HTML(Loofah.scrub_fragment(html, :escape).to_xml)
3534
node = sane.xpath("//p").first
36-
assert node.attributes['class']
37-
assert node.attributes['abbr']
38-
assert_nil node.attributes['foo']
35+
assert node.attributes["class"]
36+
assert node.attributes["abbr"]
37+
assert_nil node.attributes["foo"]
3938
end
4039

4140
def test_removal_of_illegal_url_in_href
@@ -45,14 +44,14 @@ def test_removal_of_illegal_url_in_href
4544
HTML
4645
sane = Nokogiri::HTML(Loofah.scrub_fragment(html, :escape).to_xml)
4746
nodes = sane.xpath("//a")
48-
assert_nil nodes.first.attributes['href']
49-
assert nodes.last.attributes['href']
47+
assert_nil nodes.first.attributes["href"]
48+
assert nodes.last.attributes["href"]
5049
end
5150

5251
def test_css_sanitization
5352
html = "<p style='background-color: url(\"http://foo.com/\") ; background-color: #000 ;' />"
5453
sane = Nokogiri::HTML(Loofah.scrub_fragment(html, :escape).to_xml)
55-
assert_match %r/#000/, sane.inner_html
54+
assert_match %r/#000/, sane.inner_html
5655
refute_match %r/foo\.com/, sane.inner_html
5756
end
5857

@@ -75,7 +74,7 @@ def test_fragment_with_text_nodes_leading_and_trailing
7574
def test_whitewash_on_fragment
7675
html = "safe<frameset rows=\"*\"><frame src=\"http://example.com\"></frameset> <b>description</b>"
7776
whitewashed = Loofah.scrub_document(html, :whitewash).xpath("/html/body/*").to_s
78-
assert_equal "<p>safe</p><b>description</b>", whitewashed.gsub("\n","")
77+
assert_equal "<p>safe</p><b>description</b>", whitewashed.gsub("\n", "")
7978
end
8079

8180
def test_fragment_whitewash_on_microsofty_markup
@@ -86,11 +85,11 @@ def test_fragment_whitewash_on_microsofty_markup
8685
def test_document_whitewash_on_microsofty_markup
8786
whitewashed = Loofah.document(MSWORD_HTML).scrub!(:whitewash)
8887
assert_match %r(<p>Foo <b>BOLD</b></p>), whitewashed.to_s
89-
assert_equal "<p>Foo <b>BOLD</b></p>", whitewashed.xpath("/html/body/*").to_s
88+
assert_equal "<p>Foo <b>BOLD</b></p>", whitewashed.xpath("/html/body/*").to_s
9089
end
9190

9291
def test_return_empty_string_when_nothing_left
93-
assert_equal "", Loofah.scrub_document('<script>test</script>', :prune).text
92+
assert_equal "", Loofah.scrub_document("<script>test</script>", :prune).text
9493
end
9594

9695
def test_nested_script_cdata_tags_should_be_scrubbed
@@ -145,21 +144,20 @@ def test_dont_remove_whitespace_between_tags
145144
#
146145
# https://git.gnome.org/browse/libxml2/tree/HTMLtree.c?h=v2.9.2#n714
147146
#
148-
{tag: "a", attr: "href"},
149-
{tag: "div", attr: "href"},
150-
{tag: "a", attr: "action"},
151-
{tag: "div", attr: "action"},
152-
{tag: "a", attr: "src"},
153-
{tag: "div", attr: "src"},
154-
{tag: "a", attr: "name"},
147+
{ tag: "a", attr: "href" },
148+
{ tag: "div", attr: "href" },
149+
{ tag: "a", attr: "action" },
150+
{ tag: "div", attr: "action" },
151+
{ tag: "a", attr: "src" },
152+
{ tag: "div", attr: "src" },
153+
{ tag: "a", attr: "name" },
155154
#
156155
# note that div+name is _not_ affected by the libxml2 issue.
157156
# but we test it anyway to ensure our logic isn't modifying
158157
# attributes that don't need modifying.
159158
#
160-
{tag: "div", attr: "name", unescaped: true},
159+
{ tag: "div", attr: "name", unescaped: true },
161160
].each do |config|
162-
163161
define_method "test_uri_escaping_of_#{config[:attr]}_attr_in_#{config[:tag]}_tag" do
164162
html = %{<#{config[:tag]} #{config[:attr]}='examp<!--" unsafeattr=foo()>-->le.com'>test</#{config[:tag]}>}
165163

0 commit comments

Comments
 (0)