loofah 0.4.3 → 0.4.4
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/lib/loofah.rb +1 -1
- data/lib/loofah/xss_foliate.rb +1 -1
- data/test/test_ad_hoc.rb +1 -2
- data/test/test_xss_foliate.rb +25 -8
- metadata +2 -2
- metadata.gz.sig +1 -2
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.rdoc
CHANGED
data/lib/loofah.rb
CHANGED
data/lib/loofah/xss_foliate.rb
CHANGED
data/test/test_ad_hoc.rb
CHANGED
@@ -251,7 +251,7 @@ mso-bidi-language:#0400;}
|
|
251
251
|
What's up <strong>doc</strong>?
|
252
252
|
HTML
|
253
253
|
stripped = Loofah.scrub_document(html, :prune).text
|
254
|
-
assert_equal
|
254
|
+
assert_equal %Q(What\'s up doc?).strip, stripped.strip
|
255
255
|
end
|
256
256
|
|
257
257
|
def test_dont_remove_whitespace
|
@@ -268,5 +268,4 @@ mso-bidi-language:#0400;}
|
|
268
268
|
html = "<p>this is < that "&" the other > boo'ya</p>"
|
269
269
|
assert_equal 'this is < that "&" the other > boo\'ya', Loofah.scrub_document(html, :prune).text
|
270
270
|
end
|
271
|
-
|
272
271
|
end
|
data/test/test_xss_foliate.rb
CHANGED
@@ -56,7 +56,7 @@ class TestXssFoliate < Test::Unit::TestCase
|
|
56
56
|
end
|
57
57
|
|
58
58
|
context "when passed a symbol" do
|
59
|
-
should "
|
59
|
+
should "calls the right scrubber" do
|
60
60
|
assert_nothing_raised(ArgumentError) { Post.xss_foliate :prune => :plain_text }
|
61
61
|
Loofah.expects(:scrub_fragment).with(HTML_STRING, :strip).once
|
62
62
|
Loofah.expects(:scrub_fragment).with(PLAIN_TEXT, :prune).once
|
@@ -65,7 +65,7 @@ class TestXssFoliate < Test::Unit::TestCase
|
|
65
65
|
end
|
66
66
|
|
67
67
|
context "when passed an array of symbols" do
|
68
|
-
should "
|
68
|
+
should "calls the right scrubbers" do
|
69
69
|
assert_nothing_raised(ArgumentError) {
|
70
70
|
Post.xss_foliate :prune => [:plain_text, :html_string]
|
71
71
|
}
|
@@ -76,7 +76,7 @@ class TestXssFoliate < Test::Unit::TestCase
|
|
76
76
|
end
|
77
77
|
|
78
78
|
context "when passed a string" do
|
79
|
-
should "
|
79
|
+
should "calls the right scrubber" do
|
80
80
|
assert_nothing_raised(ArgumentError) { Post.xss_foliate :prune => 'plain_text' }
|
81
81
|
Loofah.expects(:scrub_fragment).with(HTML_STRING, :strip).once
|
82
82
|
Loofah.expects(:scrub_fragment).with(PLAIN_TEXT, :prune).once
|
@@ -85,7 +85,7 @@ class TestXssFoliate < Test::Unit::TestCase
|
|
85
85
|
end
|
86
86
|
|
87
87
|
context "when passed an array of strings" do
|
88
|
-
should "
|
88
|
+
should "calls the right scrubbers" do
|
89
89
|
assert_nothing_raised(ArgumentError) {
|
90
90
|
Post.xss_foliate :prune => ['plain_text', 'html_string']
|
91
91
|
}
|
@@ -107,7 +107,7 @@ class TestXssFoliate < Test::Unit::TestCase
|
|
107
107
|
Loofah.expects(:scrub_fragment).with(HTML_STRING, :strip).once.returns(mock_doc)
|
108
108
|
Loofah.expects(:scrub_fragment).with(PLAIN_TEXT, :strip).once.returns(mock_doc)
|
109
109
|
Loofah.expects(:scrub_fragment).with(INTEGER_VALUE, :strip).never
|
110
|
-
mock_doc.expects(:
|
110
|
+
mock_doc.expects(:to_s).twice
|
111
111
|
assert new_post.valid?
|
112
112
|
end
|
113
113
|
end
|
@@ -118,9 +118,11 @@ class TestXssFoliate < Test::Unit::TestCase
|
|
118
118
|
end
|
119
119
|
|
120
120
|
should "not scrub omitted field" do
|
121
|
-
|
121
|
+
mock_doc = mock
|
122
|
+
Loofah.expects(:scrub_fragment).with(HTML_STRING, :strip).once.returns(mock_doc)
|
122
123
|
Loofah.expects(:scrub_fragment).with(PLAIN_TEXT, :strip).never
|
123
124
|
Loofah.expects(:scrub_fragment).with(INTEGER_VALUE, :strip).never
|
125
|
+
mock_doc.expects(:to_s).once
|
124
126
|
assert new_post.valid?
|
125
127
|
end
|
126
128
|
end
|
@@ -132,9 +134,11 @@ class TestXssFoliate < Test::Unit::TestCase
|
|
132
134
|
end
|
133
135
|
|
134
136
|
should "not that field appropriately" do
|
135
|
-
|
136
|
-
Loofah.expects(:scrub_fragment).with(
|
137
|
+
mock_doc = mock
|
138
|
+
Loofah.expects(:scrub_fragment).with(HTML_STRING, :strip).once.returns(mock_doc)
|
139
|
+
Loofah.expects(:scrub_fragment).with(PLAIN_TEXT, method).once.returns(mock_doc)
|
137
140
|
Loofah.expects(:scrub_fragment).with(INTEGER_VALUE, :strip).never
|
141
|
+
mock_doc.expects(:to_s).twice
|
138
142
|
assert new_post.valid?
|
139
143
|
end
|
140
144
|
end
|
@@ -167,5 +171,18 @@ class TestXssFoliate < Test::Unit::TestCase
|
|
167
171
|
end
|
168
172
|
end
|
169
173
|
|
174
|
+
context "given an XSS attempt" do
|
175
|
+
setup do
|
176
|
+
Post.xss_foliate :strip => :html_string
|
177
|
+
end
|
178
|
+
|
179
|
+
should "escape html entities" do
|
180
|
+
hackattack = "<script>alert('evil')</script>"
|
181
|
+
post = new_post :html_string => hackattack, :plain_text => hackattack
|
182
|
+
post.valid?
|
183
|
+
assert_equal "<script>alert('evil')</script>", post.html_string
|
184
|
+
assert_equal "<script>alert('evil')</script>", post.plain_text
|
185
|
+
end
|
186
|
+
end
|
170
187
|
end
|
171
188
|
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.4.
|
4
|
+
version: 0.4.4
|
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: 2010-01
|
34
|
+
date: 2010-02-01 00:00:00 -05:00
|
35
35
|
default_executable:
|
36
36
|
dependencies:
|
37
37
|
- !ruby/object:Gem::Dependency
|
metadata.gz.sig
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
ا4�`����o���Gȇ�����5�3Q�h�Aњ���@�Z3����}��> �R7ñp�p���
|
1
|
+
cُ�c,�t���T߈Z�DYF��f(��m�:i]K�j�ܓ���E3ƫ��q��;~~�Ƌm�>q�>.���Ɨ�8�=�%H�N,�!�3kR��c��A�>M�u�?���� ���.���ǣld!���1$�\���� ͺY��g�
|