form_core 0.0.7 → 0.0.8

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: b3e28335f9bf0c7a5d293b97d448027a71215c21
4
- data.tar.gz: e0b5945d3f212907ebaf2a63c53001a84099ce6d
3
+ metadata.gz: 5779e04e58d6b9ac5ac2ee67774981334045979c
4
+ data.tar.gz: a14c6f980431da776467bf80c7b02d437de365ba
5
5
  SHA512:
6
- metadata.gz: fd4f464c62523e97e1c102a3b3a5ae487acfd526f9d16b5cd946a6b564bff9a346131f73ac0ca2407677d7d3189512a8d1bee009740acc44c0460085dd12bb82
7
- data.tar.gz: 458695a18aa20db4d5e0e992183d5ff6ec67f357bea7988646cecdfe23315224a1384664f82784b999e64194cf468577cb009edc752a16c3a481c34277970e3b
6
+ metadata.gz: 5c79e9b062200bd198812b6c33c3d7280d4ad334322ca26d59514b782e97e7bdec94a17e153ca31cd9ea95cd23447928fa7ff59405274d56d06cfd7957764be3
7
+ data.tar.gz: 6e72e1414d78d00330999c7976b29ff307a7149327b0efb887a276b8093abf2793d99637f83d3627598f81a9972826672ac511afcd492716d798b25e9f9a3d98
@@ -2,15 +2,16 @@
2
2
 
3
3
  module FormCore
4
4
  class Coder
5
+ cattr_accessor :strict
6
+
5
7
  attr_reader :object_class
6
8
 
7
- def initialize(object_class, strict: false)
9
+ def initialize(object_class)
8
10
  @object_class = object_class
9
- @strict = strict
10
11
  end
11
12
 
12
13
  def strict?
13
- @strict
14
+ Coder.strict
14
15
  end
15
16
 
16
17
  def dump(_obj)
@@ -4,6 +4,16 @@ require "yaml"
4
4
 
5
5
  module FormCore
6
6
  class YAMLCoder < FormCore::Coder # :nodoc:
7
+ cattr_accessor :safe_mode
8
+
9
+ def self.whitelist_classes
10
+ @whitelist_classes ||= []
11
+ end
12
+
13
+ def safe_mode?
14
+ YAMLCoder.safe_mode
15
+ end
16
+
7
17
  def dump(obj)
8
18
  return YAML.dump({}) unless obj
9
19
 
@@ -17,7 +27,12 @@ module FormCore
17
27
  return new_or_raise_decoding_error
18
28
  end
19
29
 
20
- decoded = YAML.load(yaml)
30
+ decoded =
31
+ if safe_mode?
32
+ YAML.safe_load(yaml, YAMLCoder.whitelist_classes)
33
+ else
34
+ YAML.load(yaml)
35
+ end
21
36
  unless decoded.is_a? Hash
22
37
  return new_or_raise_decoding_error
23
38
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FormCore
4
- VERSION = "0.0.7"
4
+ VERSION = "0.0.8"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: form_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - jasl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-04 00:00:00.000000000 Z
11
+ date: 2017-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails