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 +0 -0
- data/CHANGELOG.rdoc +13 -0
- data/README.rdoc +19 -13
- data/lib/loofah.rb +1 -1
- data/lib/loofah/active_record.rb +2 -4
- data/lib/loofah/scrubbers.rb +7 -1
- data/lib/loofah/xss_foliate.rb +27 -28
- data/test/test_xss_foliate.rb +1 -1
- metadata +3 -3
- metadata.gz.sig +2 -2
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.rdoc
CHANGED
@@ -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:
|
data/README.rdoc
CHANGED
@@ -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.
|
83
|
-
|
84
|
-
|
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.
|
87
|
-
|
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
|
90
|
-
|
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.
|
94
|
-
|
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}[
|
290
|
-
*
|
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
|
data/lib/loofah.rb
CHANGED
data/lib/loofah/active_record.rb
CHANGED
@@ -2,10 +2,8 @@ module Loofah
|
|
2
2
|
#
|
3
3
|
# Loofah can scrub ActiveRecord attributes in a before_validation callback:
|
4
4
|
#
|
5
|
-
# #
|
6
|
-
#
|
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|
|
data/lib/loofah/scrubbers.rb
CHANGED
@@ -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
|
data/lib/loofah/xss_foliate.rb
CHANGED
@@ -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/
|
16
|
-
#
|
17
|
-
#
|
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/
|
62
|
-
#
|
63
|
-
#
|
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, :
|
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
|
-
|
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
|
-
|
190
|
-
|
191
|
-
|
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
|
-
|
194
|
-
fragment = Loofah.scrub_fragment(value, :escape)
|
195
|
-
self[field] = fragment.nil? ? "" : fragment.to_s
|
187
|
+
private
|
196
188
|
|
197
|
-
|
198
|
-
|
199
|
-
|
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
|
-
|
210
|
+
Loofah::XssFoliate.xss_foliate_all_models
|
212
211
|
end
|
data/test/test_xss_foliate.rb
CHANGED
@@ -125,7 +125,7 @@ class TestXssFoliate < Test::Unit::TestCase
|
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
|
-
|
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.
|
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-
|
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
|
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
|
-
|
2
|
-
|
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ȇ�����5�3Q�h�Aњ���@�Z3����}��> �R7ñp�p���
|