loofah 0.4.2 → 0.4.3

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,18 @@
1
1
  = Changelog
2
2
 
3
+ == 0.4.3 (2010-01-29)
4
+
5
+ Enhancements:
6
+
7
+ * All built-in scrubbers are accepted by ActiveRecord::Base.xss_foliate
8
+ * Loofah::XssFoliate.xss_foliate_all_models replaces use of the constant LOOFAH_XSS_FOLIATE_ALL_MODELS
9
+
10
+ Miscellaneous:
11
+
12
+ * Modified documentation for bootstrapping XssFoliate in a Rails
13
+ app, since the use of Bundler breaks the previously-documented
14
+ method. To be safe, always use an initializer file.
15
+
3
16
  == 0.4.2 (2010-01-22)
4
17
 
5
18
  Enhancements:
@@ -1,8 +1,8 @@
1
1
  = Loofah
2
2
 
3
+ * http://github.com/flavorjones/loofah
3
4
  * http://loofah.rubyforge.org
4
5
  * http://rubyforge.org/projects/loofah
5
- * http://github.com/flavorjones/loofah
6
6
 
7
7
  == Description
8
8
 
@@ -79,19 +79,19 @@ root node, you don't have a *document*, you have a *fragment*. For
79
79
  HTML, another rule of thumb is that *documents* have \<html\>
80
80
  and \<body\> tags, and *fragments* usually do not.
81
81
 
82
- HTML fragments should be parsed with Loofah.fragment. Loofah won't
83
- wrap the result in +html+ and +body+ tags, won't add a DOCTYPE
84
- declaration, and will ignore +head+ elements.
82
+ HTML fragments should be parsed with Loofah.fragment. The result won't
83
+ be wrapped in +html+ or +body+ tags, won't have a DOCTYPE declaration,
84
+ +head+ elements will be silently ignored, and multiple root nodes are
85
+ allowed.
85
86
 
86
- XML fragments should be parsed with Loofah.xml_fragment. Loofah won't
87
- add a DOCTYPE declaration and will allow multiple root nodes.
87
+ XML fragments should be parsed with Loofah.xml_fragment. The result
88
+ won't have a DOCTYPE declaration, and multiple root nodes are allowed.
88
89
 
89
- HTML documents should be parsed with Loofah.document, which will add
90
- the DOCTYPE declaration, and properly handle +head+ and +body+
91
- elements.
90
+ HTML documents should be parsed with Loofah.document. The result will
91
+ have a DOCTYPE declaration, along with +html+, +head+ and +body+ tags.
92
92
 
93
- XML documents should be parsed with Loofah.xml_document. Loofah will
94
- make sure there's a DOCTYPE declaration and a single root node.
93
+ XML documents should be parsed with Loofah.xml_document. The result
94
+ will have a DOCTYPE declaration and a single root node.
95
95
 
96
96
  === Loofah::HTML::Document and Loofah::HTML::DocumentFragment
97
97
 
@@ -286,8 +286,8 @@ And the IRC channel is \#loofah on freenode.
286
286
 
287
287
  == Authors
288
288
 
289
- * {Mike Dalessio}[mailto:mike.dalessio@gmail.com] (@flavorjones)
290
- * {Bryan Helmkamp}[mailto:bryan@brynary.com]
289
+ * {Mike Dalessio}[http://mike.daless.io] (@flavorjones[http://twitter.com/flavorjones])
290
+ * Bryan Helmkamp
291
291
 
292
292
  Featuring code contributed by:
293
293
 
@@ -300,6 +300,12 @@ Featuring code contributed by:
300
300
 
301
301
  And a big shout-out to Corey Innis for the name, and feedback on the API.
302
302
 
303
+ == Thank You
304
+
305
+ The following people have generously donated via the Pledgie[http://pledgie.com] badge on the {Loofah github page}[http://github.com/flavorjones/loofah]:
306
+
307
+ * Bill Harding
308
+
303
309
  == Historical Note
304
310
 
305
311
  This library was formerly known as Dryopteris, which was a very bad
@@ -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.2'
29
+ VERSION = '0.4.3'
30
30
 
31
31
  # The minimum required version of Nokogiri
32
32
  REQUIRED_NOKOGIRI_VERSION = '1.3.3'
@@ -2,10 +2,8 @@ module Loofah
2
2
  #
3
3
  # Loofah can scrub ActiveRecord attributes in a before_validation callback:
4
4
  #
5
- # # in environment.rb
6
- # Rails::Initializer.run do |config|
7
- # config.gem 'loofah'
8
- # end
5
+ # # config/initializers/loofah.rb
6
+ # require 'loofah'
9
7
  #
10
8
  # # db/schema.rb
11
9
  # create_table "posts" do |t|
@@ -60,7 +60,6 @@ module Loofah
60
60
  #
61
61
  #
62
62
  module Scrubbers
63
-
64
63
  #
65
64
  # === scrub!(:strip)
66
65
  #
@@ -195,5 +194,12 @@ module Loofah
195
194
  :strip => Strip,
196
195
  :nofollow => NoFollow
197
196
  }
197
+
198
+ #
199
+ # Returns an array of symbols representing the built-in scrubbers
200
+ #
201
+ def self.scrubber_symbols
202
+ MAP.keys
203
+ end
198
204
  end
199
205
  end
@@ -12,11 +12,9 @@ module Loofah
12
12
  #
13
13
  # If you'd like to scrub all fields in all your models (and perhaps *opt-out* in specific models):
14
14
  #
15
- # # config/environment
16
- # LOOFAH_XSS_FOLIATE_ALL_MODELS = true
17
- # Rails::Initializer.run do |config|
18
- # config.gem "loofah"
19
- # end
15
+ # # config/initializers/loofah.rb
16
+ # require 'loofah'
17
+ # Loofah::XssFoliate.xss_foliate_all_models
20
18
  #
21
19
  # # db/schema.rb
22
20
  # create_table "posts" do |t|
@@ -58,11 +56,9 @@ module Loofah
58
56
  #
59
57
  # Alternatively, if you would like to *opt-in* to the models and attributes that are sanitized:
60
58
  #
61
- # # config/environment.rb
62
- # LOOFAH_XSS_FOLIATE_ALL_MODELS = false # default, this line could be omitted
63
- # Rails::Initializer.run do |config|
64
- # config.gem "loofah"
65
- # end
59
+ # # config/initializers/loofah.rb
60
+ # require 'loofah'
61
+ # ## note omission of call to Loofah::XssFoliate.xss_foliate_all_models
66
62
  #
67
63
  # # db/schema.rb
68
64
  # create_table "posts" do |t|
@@ -87,7 +83,7 @@ module Loofah
87
83
  #
88
84
  module ClassMethods
89
85
  # :stopdoc:
90
- VALID_OPTIONS = [:except, :strip, :escape, :prune, :text, :html5lib_sanitize, :sanitize]
86
+ VALID_OPTIONS = [:except, :html5lib_sanitize, :sanitize] + Loofah::Scrubbers.scrubber_symbols
91
87
  ALIASED_OPTIONS = {:html5lib_sanitize => :escape, :sanitize => :strip}
92
88
  REAL_OPTIONS = VALID_OPTIONS - ALIASED_OPTIONS.keys
93
89
  # :startdoc:
@@ -165,7 +161,6 @@ module Loofah
165
161
  end
166
162
 
167
163
  module InstanceMethods
168
-
169
164
  def xss_foliate_fields # :nodoc:
170
165
  # fix a bug with Rails internal AR::Base models that get loaded before
171
166
  # the plugin, like CGI::Sessions::ActiveRecordStore::Session
@@ -179,34 +174,38 @@ module Loofah
179
174
 
180
175
  next if value.nil? || !value.is_a?(String)
181
176
 
182
- if xss_foliate_options[:except].include?(field)
183
- next
177
+ next if xss_foliate_options[:except].include?(field)
184
178
 
185
- elsif xss_foliate_options[:strip].include?(field)
186
- fragment = Loofah.scrub_fragment(value, :strip)
187
- self[field] = fragment.nil? ? "" : fragment.to_s
179
+ next if xss_foliated_with_standard_scrubber(field)
188
180
 
189
- elsif xss_foliate_options[:prune].include?(field)
190
- fragment = Loofah.scrub_fragment(value, :prune)
191
- self[field] = fragment.nil? ? "" : fragment.to_s
181
+ # :text if we're here
182
+ fragment = Loofah.scrub_fragment(value, :strip)
183
+ self[field] = fragment.nil? ? "" : fragment.text
184
+ end
185
+ end
192
186
 
193
- elsif xss_foliate_options[:escape].include?(field)
194
- fragment = Loofah.scrub_fragment(value, :escape)
195
- self[field] = fragment.nil? ? "" : fragment.to_s
187
+ private
196
188
 
197
- else # :text
198
- fragment = Loofah.scrub_fragment(value, :strip)
199
- self[field] = fragment.nil? ? "" : fragment.text
189
+ def xss_foliated_with_standard_scrubber(field)
190
+ Loofah::Scrubbers.scrubber_symbols.each do |method|
191
+ if xss_foliate_options[method].include?(field)
192
+ fragment = Loofah.scrub_fragment(self[field], method)
193
+ self[field] = fragment.nil? ? "" : fragment.to_s
194
+ return true
200
195
  end
201
196
  end
202
-
197
+ false
203
198
  end
204
199
  end
200
+
201
+ def self.xss_foliate_all_models
202
+ ActiveRecord::Base.xss_foliate
203
+ end
205
204
  end
206
205
  end
207
206
 
208
207
  ActiveRecord::Base.extend(Loofah::XssFoliate::ClassMethods)
209
208
 
210
209
  if defined?(LOOFAH_XSS_FOLIATE_ALL_MODELS) && LOOFAH_XSS_FOLIATE_ALL_MODELS
211
- ActiveRecord::Base.xss_foliate
210
+ Loofah::XssFoliate.xss_foliate_all_models
212
211
  end
@@ -125,7 +125,7 @@ class TestXssFoliate < Test::Unit::TestCase
125
125
  end
126
126
  end
127
127
 
128
- [:strip, :escape, :prune].each do |method|
128
+ Loofah::Scrubbers.scrubber_symbols.each do |method|
129
129
  context "declaring one field to be scrubbed with #{method}" do
130
130
  setup do
131
131
  Post.xss_foliate method => [:plain_text]
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.2
4
+ version: 0.4.3
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-23 00:00:00 -05:00
34
+ date: 2010-01-31 00:00:00 -05:00
35
35
  default_executable:
36
36
  dependencies:
37
37
  - !ruby/object:Gem::Dependency
@@ -143,7 +143,7 @@ files:
143
143
  - test/test_scrubbers.rb
144
144
  - test/test_xss_foliate.rb
145
145
  has_rdoc: true
146
- homepage: http://loofah.rubyforge.org
146
+ homepage: http://github.com/flavorjones/loofah
147
147
  licenses: []
148
148
 
149
149
  post_install_message:
metadata.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- L���l�~��j��{V ��}��!L���$-�5�չ�(>��am��|:{0 ֑��ߌ���OKid�$�Jq|%���ƽ�k
2
- X]��,���<�)���)T��q��Z����u�Haã�ju=��te�d���?":���md�#���ܷS]��,�`_oI
1
+ 7S���V"�<jw�'���\�y�qpҩ�@*��]�<��@�F+������B�o��0�L��,��Ud����!A!�K;�oœ�A .e��lm.��xd�l��^i,:$�_�Om��J�
2
+ ا4�`����o���Gȇ�����53Qh�Aњ���@�Z3����}��> �R7 ñpp���