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 CHANGED
Binary file
@@ -1,5 +1,11 @@
1
1
  = Changelog
2
2
 
3
+ == 0.4.4 (2010-02-01)
4
+
5
+ Bug fixes:
6
+
7
+ * Loofah::XssFoliate was not properly escaping HTML entities when implicitly scrubbing a string attribute. GH #17
8
+
3
9
  == 0.4.3 (2010-01-29)
4
10
 
5
11
  Enhancements:
@@ -26,7 +26,7 @@ require 'loofah/helpers'
26
26
  #
27
27
  module Loofah
28
28
  # The version of Loofah you are using
29
- VERSION = '0.4.3'
29
+ VERSION = '0.4.4'
30
30
 
31
31
  # The minimum required version of Nokogiri
32
32
  REQUIRED_NOKOGIRI_VERSION = '1.3.3'
@@ -180,7 +180,7 @@ module Loofah
180
180
 
181
181
  # :text if we're here
182
182
  fragment = Loofah.scrub_fragment(value, :strip)
183
- self[field] = fragment.nil? ? "" : fragment.text
183
+ self[field] = fragment.nil? ? "" : fragment.to_s
184
184
  end
185
185
  end
186
186
 
@@ -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 "What's up doc?".strip, stripped.strip
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 &lt; that &quot;&amp;&quot; the other &gt; boo&apos;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
@@ -56,7 +56,7 @@ class TestXssFoliate < Test::Unit::TestCase
56
56
  end
57
57
 
58
58
  context "when passed a symbol" do
59
- should "do the right thing" do
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 "do the right thing" do
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 "do the right thing" do
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 "do the right thing" do
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(:text).twice
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
- Loofah.expects(:scrub_fragment).with(HTML_STRING, :strip).once
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
- Loofah.expects(:scrub_fragment).with(HTML_STRING, :strip).once
136
- Loofah.expects(:scrub_fragment).with(PLAIN_TEXT, method).once
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 = "&lt;script&gt;alert('evil')&lt;/script&gt;"
181
+ post = new_post :html_string => hackattack, :plain_text => hackattack
182
+ post.valid?
183
+ assert_equal "&lt;script&gt;alert('evil')&lt;/script&gt;", post.html_string
184
+ assert_equal "&lt;script&gt;alert('evil')&lt;/script&gt;", 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.3
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-31 00:00:00 -05:00
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
- 7S���V"�<jw'���\�yqpҩ�@*��]�<��@�F+������Bo��0�L��,��Ud����!A!�K;�oœ�A .e��lm.��xd�l��^i,:$�_�Om��J�
2
- ا4�`����o���Gȇ�����5�3Q�h�Aњ���@�Z3����}��> �R7 ñp�p���
1
+ cُ�c,�t���T߈ZDYF��f( �m�:i]Kj�ܓ���E3ƫ��q��;~~�Ƌm�>q�>.���Ɨ�8�=�%H�N,�!�3kR��c��A�>Mu�?���� ���.���ǣld!���1$�\���� ͺY��g�