Skip to content

Commit

Permalink
Dont allow unserializing classes with a destructor - 4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
jderusse committed Jan 12, 2021
1 parent 7a4176a commit b8ad6ca
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Part/DataPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,13 @@ public function __wakeup()
$r->setValue($this, $this->_headers);
unset($this->_headers);

if (!\is_array($this->_parent)) {
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}
foreach (['body', 'charset', 'subtype', 'disposition', 'name', 'encoding'] as $name) {
if (null !== $this->_parent[$name] && !\is_string($this->_parent[$name])) {
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}
$r = new \ReflectionProperty(TextPart::class, $name);
$r->setAccessible(true);
$r->setValue($this, $this->_parent[$name]);
Expand Down

0 comments on commit b8ad6ca

Please sign in to comment.