This repository has been archived by the owner on Jan 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from MatthiasKuehneEllerhold/unserialize-white…
…list Unserialize whitelist
- Loading branch information
Showing
4 changed files
with
170 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2018 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
namespace Zend\Serializer\Adapter; | ||
|
||
use Zend\Json\Json as ZendJson; | ||
use Zend\Serializer\Exception; | ||
|
||
class PhpSerializeOptions extends AdapterOptions | ||
{ | ||
/** | ||
* The list of allowed classes for unserialization (PHP 7.0+) | ||
* Possible values: | ||
* Array of class names that are allowed to be unserialized | ||
* or true if all classes should be allowed (behavior of pre PHP 7.0) | ||
* or false if no classes should be allowed | ||
* | ||
* @var string[]|bool | ||
*/ | ||
protected $unserializeClassWhitelist = true; | ||
|
||
/** | ||
* @param string[]|bool $unserializeClassWhitelist | ||
* | ||
* @return PhpSerializeOptions | ||
*/ | ||
public function setUnserializeClassWhitelist($unserializeClassWhitelist) | ||
{ | ||
if (($unserializeClassWhitelist !== true) && (PHP_MAJOR_VERSION < 7)) { | ||
throw new Exception\InvalidArgumentException( | ||
'Class whitelist for unserialize() is only available on PHP 7.0 or higher.' | ||
); | ||
} | ||
|
||
$this->unserializeClassWhitelist = $unserializeClassWhitelist; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return string[]|bool | ||
*/ | ||
public function getUnserializeClassWhitelist() | ||
{ | ||
return $this->unserializeClassWhitelist; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters