8
8
use Magento \Framework \App \Cache \TypeListInterface ;
9
9
use Magento \Framework \App \Config \ScopeConfigInterface ;
10
10
use Magento \Framework \App \Config \Value ;
11
+ use Magento \Framework \App \ObjectManager ;
11
12
use Magento \Framework \Data \Collection \AbstractDb ;
12
13
use Magento \Framework \Math \Random ;
13
14
use Magento \Framework \Model \Context ;
14
15
use Magento \Framework \Model \ResourceModel \AbstractResource ;
15
16
use Magento \Framework \Registry ;
17
+ use Magento \Framework \Unserialize \SecureUnserializer ;
16
18
17
19
/**
18
20
* Class CountryCreditCard
@@ -24,6 +26,11 @@ class CountryCreditCard extends Value
24
26
*/
25
27
protected $ mathRandom ;
26
28
29
+ /**
30
+ * @var SecureUnserializer
31
+ */
32
+ private $ secureUnserializer ;
33
+
27
34
/**
28
35
* @param \Magento\Framework\Model\Context $context
29
36
* @param \Magento\Framework\Registry $registry
@@ -32,6 +39,7 @@ class CountryCreditCard extends Value
32
39
* @param \Magento\Framework\Math\Random $mathRandom
33
40
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
34
41
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
42
+ * @param SecureUnserializer|null $secureUnserializer
35
43
* @param array $data
36
44
*/
37
45
public function __construct (
@@ -42,9 +50,11 @@ public function __construct(
42
50
Random $ mathRandom ,
43
51
AbstractResource $ resource = null ,
44
52
AbstractDb $ resourceCollection = null ,
53
+ SecureUnserializer $ secureUnserializer = null ,
45
54
array $ data = []
46
55
) {
47
56
$ this ->mathRandom = $ mathRandom ;
57
+ $ this ->secureUnserializer = $ secureUnserializer ?: ObjectManager::getInstance ()->get (SecureUnserializer::class);
48
58
parent ::__construct ($ context , $ registry , $ config , $ cacheTypeList , $ resource , $ resourceCollection , $ data );
49
59
}
50
60
@@ -58,7 +68,7 @@ public function beforeSave()
58
68
$ value = $ this ->getValue ();
59
69
if (!is_array ($ value )) {
60
70
try {
61
- $ value = unserialize ($ value );
71
+ $ value = $ this -> secureUnserializer -> unserialize ($ value );
62
72
} catch (\InvalidArgumentException $ e ) {
63
73
$ value = [];
64
74
}
0 commit comments