88use Magento \Framework \App \Cache \TypeListInterface ;
99use Magento \Framework \App \Config \ScopeConfigInterface ;
1010use Magento \Framework \App \Config \Value ;
11+ use Magento \Framework \App \ObjectManager ;
1112use Magento \Framework \Data \Collection \AbstractDb ;
1213use Magento \Framework \Math \Random ;
1314use Magento \Framework \Model \Context ;
1415use Magento \Framework \Model \ResourceModel \AbstractResource ;
1516use Magento \Framework \Registry ;
17+ use Magento \Framework \Unserialize \SecureUnserializer ;
1618
1719/**
1820 * Class CountryCreditCard
@@ -24,6 +26,11 @@ class CountryCreditCard extends Value
2426 */
2527 protected $ mathRandom ;
2628
29+ /**
30+ * @var SecureUnserializer
31+ */
32+ private $ secureUnserializer ;
33+
2734 /**
2835 * @param \Magento\Framework\Model\Context $context
2936 * @param \Magento\Framework\Registry $registry
@@ -32,6 +39,7 @@ class CountryCreditCard extends Value
3239 * @param \Magento\Framework\Math\Random $mathRandom
3340 * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
3441 * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
42+ * @param SecureUnserializer|null $secureUnserializer
3543 * @param array $data
3644 */
3745 public function __construct (
@@ -42,9 +50,11 @@ public function __construct(
4250 Random $ mathRandom ,
4351 AbstractResource $ resource = null ,
4452 AbstractDb $ resourceCollection = null ,
53+ SecureUnserializer $ secureUnserializer = null ,
4554 array $ data = []
4655 ) {
4756 $ this ->mathRandom = $ mathRandom ;
57+ $ this ->secureUnserializer = $ secureUnserializer ?: ObjectManager::getInstance ()->get (SecureUnserializer::class);
4858 parent ::__construct ($ context , $ registry , $ config , $ cacheTypeList , $ resource , $ resourceCollection , $ data );
4959 }
5060
@@ -58,7 +68,7 @@ public function beforeSave()
5868 $ value = $ this ->getValue ();
5969 if (!is_array ($ value )) {
6070 try {
61- $ value = unserialize ($ value );
71+ $ value = $ this -> secureUnserializer -> unserialize ($ value );
6272 } catch (\InvalidArgumentException $ e ) {
6373 $ value = [];
6474 }
0 commit comments