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 +4 -4
- data/lib/form_core/coder.rb +4 -3
- data/lib/form_core/coders/yaml_coder.rb +16 -1
- data/lib/form_core/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5779e04e58d6b9ac5ac2ee67774981334045979c
|
4
|
+
data.tar.gz: a14c6f980431da776467bf80c7b02d437de365ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c79e9b062200bd198812b6c33c3d7280d4ad334322ca26d59514b782e97e7bdec94a17e153ca31cd9ea95cd23447928fa7ff59405274d56d06cfd7957764be3
|
7
|
+
data.tar.gz: 6e72e1414d78d00330999c7976b29ff307a7149327b0efb887a276b8093abf2793d99637f83d3627598f81a9972826672ac511afcd492716d798b25e9f9a3d98
|
data/lib/form_core/coder.rb
CHANGED
@@ -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
|
9
|
+
def initialize(object_class)
|
8
10
|
@object_class = object_class
|
9
|
-
@strict = strict
|
10
11
|
end
|
11
12
|
|
12
13
|
def strict?
|
13
|
-
|
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 =
|
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
|
data/lib/form_core/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2017-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|