sanitize 4.2.0 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sanitize might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: abb1df5c4bd3af158380b4fd3125ab354f0d8cfa
4
- data.tar.gz: 9e418edd6b360cb64579d5cd1e57f9e4acb8e527
3
+ metadata.gz: a202a438bce353e37e37dc9c40522cea2269b934
4
+ data.tar.gz: 226373f045e2d040b1d0902b34b873187257cd65
5
5
  SHA512:
6
- metadata.gz: 78570f43744763cddcc1eee64bc62f2d315cbf544b21c022ee49184b30f680d294388d8d63fac8bd6fefdaff7acc202bdcd30ff3dc7418d0bd802c661eeb2fad
7
- data.tar.gz: 2fe95ba29fede36ba37f0d28e58336369cf3745936ef9397ee27872f8586e25ba10568911d67225928aa905141b6a692a2afc5d959f25dc329014cd5ecff9def
6
+ metadata.gz: 1fec7ba0e5c844402e5723ec9c51645a2d801de463af61cb6b893c6bdcc7a0901cc13d737ef42408e162335bad69440c4d575e903864f385eb0973b3f57e6266
7
+ data.tar.gz: 1f38a977ffcbf56d321c808e39e26d5b44fe8c1826b11ee977e9ffe34c45c59b2ff896e65a9f5e799efab9598e5daa959d33fee3998d591d0fd2ed8989864d06
data/HISTORY.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Sanitize History
2
2
 
3
+ ## 4.3.0 (2016-09-20)
4
+
5
+ * Methods can now be used as transformers. [@Skipants - #155][155]
6
+
7
+ [155]:https://github.com/rgrove/sanitize/pull/155
8
+
9
+
3
10
  ## 4.2.0 (2016-08-22)
4
11
 
5
12
  * Added `-webkit-font-smoothing` to the relaxed CSS config. [@louim - #154][154]
@@ -77,7 +77,7 @@ class Sanitize
77
77
  def initialize(config = {})
78
78
  @config = Config.merge(Config::DEFAULT, config)
79
79
 
80
- @transformers = Array(@config[:transformers].dup)
80
+ @transformers = Array(@config[:transformers]).dup
81
81
 
82
82
  # Default transformers always run at the end of the chain, after any custom
83
83
  # transformers.
@@ -52,7 +52,7 @@ class Sanitize
52
52
  # Returns `true` if `dup` may be safely called on _value_, `false`
53
53
  # otherwise.
54
54
  def self.can_dupe?(value)
55
- !(true == value || false == value || value.nil? || Numeric === value || Symbol === value)
55
+ !(true == value || false == value || value.nil? || Method === value || Numeric === value || Symbol === value)
56
56
  end
57
57
  private_class_method :can_dupe?
58
58
 
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  class Sanitize
4
- VERSION = '4.2.0'
4
+ VERSION = '4.3.0'
5
5
  end
@@ -2,6 +2,17 @@
2
2
  require_relative 'common'
3
3
 
4
4
  describe 'Sanitize' do
5
+ describe 'initializer' do
6
+ it 'should not modify a transformers array in the given config' do
7
+ transformers = [
8
+ lambda {}
9
+ ]
10
+
11
+ Sanitize.new({ :transformers => transformers })
12
+ transformers.length.must_equal(1)
13
+ end
14
+ end
15
+
5
16
  describe 'instance methods' do
6
17
  before do
7
18
  @s = Sanitize.new
@@ -77,6 +77,12 @@ describe 'Transformers' do
77
77
  called.must_equal true
78
78
  end
79
79
 
80
+ it 'should accept a method transformer' do
81
+ def transformer(env); end
82
+ Sanitize.fragment('<div>foo</div>', :transformers => method(:transformer))
83
+ .must_equal(' foo ')
84
+ end
85
+
80
86
  describe 'Image whitelist transformer' do
81
87
  require 'uri'
82
88
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sanitize
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 4.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Grove
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-23 00:00:00.000000000 Z
11
+ date: 2016-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: crass