sanitize-rails 0.9.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 92119626e5ebb931fe890e757c3c2fc9b287a351
4
- data.tar.gz: 315002fac67c6275c2b6ef6eafeef4f946cf3f52
3
+ metadata.gz: 6ec8f2b92a344e0040ed2e8b9ab5f2f04aaeeca3
4
+ data.tar.gz: f0f4f8f6956493fa27bd846d8ddc6152ba93c74c
5
5
  SHA512:
6
- metadata.gz: 452ec0f4ac318d174ed4625646ad62e9f3524faa926eaff28726d2fb1e57127ac9db389bf1aadbd1f312da30c760ea12beed184e4d69cb739d50070ccd710aae
7
- data.tar.gz: 44077d2a5c5a330f61c2903649b0ef71e246af81d6323047713d69d21292c0893af6883cf41168b2cac25547ee5397c89c47ae4bf647a2d1015d9c11400a60ad
6
+ metadata.gz: 98043ba7284b51877fb1b2613cf1fb4c54b1ea7e76331e230b0f0613e180730db6427f134e10d7f01176fb82b173c9b8c43b7d1b95af8c666b3edd2ad7efa264
7
+ data.tar.gz: 2ccaf00041d33e2eb027e746d945f5d92f172237d4ae8d452c37eb306a3d672c64824656943213f0e15b52dcc729c9823cd52ad78a6ddd3310d45c2f0f4be91b
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  Gemfile.lock
7
7
  html
8
8
  pkg
9
+ .idea
@@ -22,10 +22,10 @@ module Sanitize::Rails
22
22
 
23
23
  define_method(sanitizer) do # # Unrolled version
24
24
  fields.each do |field| #
25
- value = send(field)
25
+ value = read_attribute(field)
26
26
  unless value.blank? # def sanitize_fieldA_fieldB
27
- sanitized = Engine.clean(value) # self.fieldA = Engine.clean(self.fieldA) unless fieldA.blank?
28
- send("#{field}=", sanitized) # self.fieldB = Engine.clean(self.fieldB) unless fieldB.blank?
27
+ sanitized = Engine.clean(value) # write_attribute(fieldA, Engine.clean(read_attribute(fieldA))) unless fieldA.blank?
28
+ write_attribute(field, sanitized) # write_attribute(fieldB, Engine.clean(read_attribute(fieldB))) unless fieldB.blank?
29
29
  end # end
30
30
  end #
31
31
  end # end
@@ -32,13 +32,14 @@ module Sanitize::Rails
32
32
  # means that text passed through `Sanitize::Rails::Engine.clean`
33
33
  # will not be escaped by ActionView's XSS filtering utilities.
34
34
  def clean(string)
35
- ::ActiveSupport::SafeBuffer.new string.to_s.dup.tap { |s| clean!(s) }
35
+ ::ActiveSupport::SafeBuffer.new cleaner.fragment(string)
36
36
  end
37
37
 
38
38
  # Sanitizes the given `string` in place and does NOT mark it as `html_safe`
39
39
  #
40
40
  def clean!(string)
41
- cleaner.clean!(string.to_s).to_s
41
+ return '' if string.nil?
42
+ string.replace cleaner.fragment(string)
42
43
  end
43
44
 
44
45
  def callback_for(options) #:nodoc:
@@ -1,5 +1,5 @@
1
1
  class Sanitize
2
2
  module Rails
3
- VERSION = '0.9.1'
3
+ VERSION = '1.0.0'
4
4
  end
5
5
  end
@@ -18,5 +18,5 @@ Gem::Specification.new do |s|
18
18
  s.files = `git ls-files`.split("\n")
19
19
 
20
20
  s.add_dependency "rails", ">= 3.0"
21
- s.add_dependency "sanitize", "~> 2.0"
21
+ s.add_dependency "sanitize", "~> 3.0"
22
22
  end
@@ -17,7 +17,7 @@ class SanitizeRailsStringExtensionTest < Minitest::Test
17
17
  assert_instance_of SanitizableString, sanitizable_string
18
18
 
19
19
  new_string = sanitizable_string.sanitize_as_html!
20
- assert_instance_of String, new_string
20
+ assert_instance_of SanitizableString, new_string
21
21
  end
22
22
 
23
23
  def test_respond_to_sanitize_as_html
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sanitize-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcello Barnaba
@@ -32,14 +32,14 @@ dependencies:
32
32
  requirements:
33
33
  - - "~>"
34
34
  - !ruby/object:Gem::Version
35
- version: '2.0'
35
+ version: '3.0'
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
- version: '2.0'
42
+ version: '3.0'
43
43
  description:
44
44
  email:
45
45
  - vjt@openssl.it