sanitize-rails 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -1
- data/lib/sanitize/rails.rb +11 -9
- metadata +2 -2
data/README.md
CHANGED
data/lib/sanitize/rails.rb
CHANGED
@@ -4,7 +4,7 @@ require 'sanitize'
|
|
4
4
|
require 'sanitize/railtie' if defined? Rails
|
5
5
|
|
6
6
|
module Sanitize::Rails
|
7
|
-
Version = '0.
|
7
|
+
Version = '0.6.0'
|
8
8
|
|
9
9
|
# Configures the sanitizer with the given `config` hash.
|
10
10
|
#
|
@@ -38,13 +38,13 @@ module Sanitize::Rails
|
|
38
38
|
# Returns a copy of the given `string` after sanitizing it
|
39
39
|
#
|
40
40
|
def clean(string)
|
41
|
-
|
41
|
+
clean!(string.dup)
|
42
42
|
end
|
43
43
|
|
44
|
-
# Sanitizes the given string in place
|
44
|
+
# Sanitizes the given `string` in place
|
45
45
|
#
|
46
46
|
def clean!(string)
|
47
|
-
cleaner.clean!(string)
|
47
|
+
cleaner.clean!(string)
|
48
48
|
end
|
49
49
|
|
50
50
|
def callback_for(options) #:nodoc:
|
@@ -97,11 +97,13 @@ module Sanitize::Rails
|
|
97
97
|
callback = Engine.callback_for(options)
|
98
98
|
sanitizer = Engine.method_for(fields)
|
99
99
|
|
100
|
-
define_method(sanitizer) do #
|
101
|
-
fields.each do |field| #
|
102
|
-
|
103
|
-
|
104
|
-
|
100
|
+
define_method(sanitizer) do # # Unrolled version
|
101
|
+
fields.each do |field| #
|
102
|
+
unless field.blank? # def sanitize_fieldA_fieldB
|
103
|
+
sanitized = Engine.clean(send(field)) # self.fieldA = Engine.clean(self.fieldA) unless fieldA.blank?
|
104
|
+
send("#{field}=", sanitized) # self.fieldB = Engine.clean(self.fieldB) unless fieldB.blank?
|
105
|
+
end # end
|
106
|
+
end #
|
105
107
|
end # end
|
106
108
|
|
107
109
|
protected sanitizer # protected :sanitize_fieldA_fieldB
|