loofah 0.3.0 → 0.3.1
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.
- data.tar.gz.sig +0 -0
- data/CHANGELOG.rdoc +6 -0
- data/Rakefile +1 -0
- data/lib/loofah.rb +1 -1
- data/lib/loofah/html/document_fragment.rb +8 -0
- data/lib/loofah/scrubber.rb +0 -8
- data/test/test_ad_hoc.rb +5 -14
- data/test/test_scrubber.rb +25 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.rdoc
CHANGED
data/Rakefile
CHANGED
data/lib/loofah.rb
CHANGED
data/lib/loofah/scrubber.rb
CHANGED
@@ -23,14 +23,6 @@ module Loofah
|
|
23
23
|
self
|
24
24
|
end
|
25
25
|
|
26
|
-
#
|
27
|
-
# Returns the HTML markup contained by the fragment or document
|
28
|
-
#
|
29
|
-
def to_s
|
30
|
-
__sanitize_roots.children.to_s
|
31
|
-
end
|
32
|
-
alias :serialize :to_s
|
33
|
-
|
34
26
|
#
|
35
27
|
# Returns a plain-text version of the markup contained by the fragment or document
|
36
28
|
#
|
data/test/test_ad_hoc.rb
CHANGED
@@ -65,7 +65,7 @@ class TestAdHoc < Test::Unit::TestCase
|
|
65
65
|
|
66
66
|
def test_whitewash_on_fragment
|
67
67
|
html = "safe<frameset rows=\"*\"><frame src=\"http://example.com\"></frameset> <b>description</b>"
|
68
|
-
whitewashed = Loofah.scrub_document(html, :whitewash).to_s
|
68
|
+
whitewashed = Loofah.scrub_document(html, :whitewash).xpath("/html/body/*").to_s
|
69
69
|
assert_equal "<p>safe</p><b>description</b>", whitewashed.gsub("\n","")
|
70
70
|
end
|
71
71
|
|
@@ -135,24 +135,15 @@ mso-bidi-language:#0400;}
|
|
135
135
|
<p class="MsoNormal">Foo <b style="">BOLD<o:p></o:p></b></p>
|
136
136
|
EOHTML
|
137
137
|
|
138
|
-
def test_deprecated_whitewash_fragment_on_microsofty_markup
|
139
|
-
whitewashed = Loofah.scrub_fragment(MSWORD_HTML.chomp, :whitewash).to_s
|
140
|
-
assert_equal "<p>Foo <b>BOLD</b></p>", whitewashed
|
141
|
-
end
|
142
|
-
|
143
|
-
def test_deprecated_whitewash_on_microsofty_markup
|
144
|
-
whitewashed = Loofah.scrub_document(MSWORD_HTML, :whitewash).to_s
|
145
|
-
assert_equal "<p>Foo <b>BOLD</b></p>", whitewashed
|
146
|
-
end
|
147
|
-
|
148
138
|
def test_fragment_whitewash_on_microsofty_markup
|
149
|
-
whitewashed = Loofah.fragment(MSWORD_HTML
|
139
|
+
whitewashed = Loofah.fragment(MSWORD_HTML).scrub!(:whitewash)
|
150
140
|
assert_equal "<p>Foo <b>BOLD</b></p>", whitewashed.to_s
|
151
141
|
end
|
152
142
|
|
153
143
|
def test_document_whitewash_on_microsofty_markup
|
154
|
-
whitewashed = Loofah.document(MSWORD_HTML
|
155
|
-
|
144
|
+
whitewashed = Loofah.document(MSWORD_HTML).scrub!(:whitewash)
|
145
|
+
assert_contains whitewashed.to_s, %r(<p>Foo <b>BOLD</b></p>)
|
146
|
+
assert_equal "<p>Foo <b>BOLD</b></p>", whitewashed.xpath("/html/body/*").to_s
|
156
147
|
end
|
157
148
|
|
158
149
|
def test_return_empty_string_when_nothing_left
|
data/test/test_scrubber.rb
CHANGED
@@ -97,4 +97,29 @@ class TestScrubber < Test::Unit::TestCase
|
|
97
97
|
Loofah.scrub_document(:string_or_io, :method)
|
98
98
|
end
|
99
99
|
|
100
|
+
def test_document_to_s
|
101
|
+
doc = Loofah.scrub_document "<html><head><title>quux</title></head><body><div>foo</div></body></html>", :prune
|
102
|
+
assert_not_nil doc.xpath("/html").first
|
103
|
+
assert_not_nil doc.xpath("/html/head").first
|
104
|
+
assert_not_nil doc.xpath("/html/body").first
|
105
|
+
|
106
|
+
assert_contains doc.to_s, /<!DOCTYPE/
|
107
|
+
assert_contains doc.to_s, /<html>/
|
108
|
+
assert_contains doc.to_s, /<head>/
|
109
|
+
assert_contains doc.to_s, /<body>/
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_document_serialize
|
113
|
+
doc = Loofah.scrub_document "<html><head><title>quux</title></head><body><div>foo</div></body></html>", :prune
|
114
|
+
|
115
|
+
assert_not_nil doc.xpath("/html").first
|
116
|
+
assert_not_nil doc.xpath("/html/head").first
|
117
|
+
assert_not_nil doc.xpath("/html/body").first
|
118
|
+
|
119
|
+
assert_contains doc.serialize, /<!DOCTYPE/
|
120
|
+
assert_contains doc.serialize, /<html>/
|
121
|
+
assert_contains doc.serialize, /<head>/
|
122
|
+
assert_contains doc.serialize, /<body>/
|
123
|
+
end
|
124
|
+
|
100
125
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loofah
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Dalessio
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
FlqnTjy13J3nD30uxy9a1g==
|
32
32
|
-----END CERTIFICATE-----
|
33
33
|
|
34
|
-
date: 2009-10-
|
34
|
+
date: 2009-10-12 00:00:00 -04:00
|
35
35
|
default_executable:
|
36
36
|
dependencies:
|
37
37
|
- !ruby/object:Gem::Dependency
|
metadata.gz.sig
CHANGED
Binary file
|