bug #39795 Dont allow unserializing classes with a destructor - 5.1 (jderusse)
This PR was merged into the 5.1 branch.
Discussion
----------
Dont allow unserializing classes with a destructor - 5.1
| Q | A
| ------------- | ---
| Branch? | 5.1
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
Prevent destructors with side-effects from being unserialized
Commits
-------
07402f4af3
Dont allow unserializing classes with a destructor - 5.1
This commit is contained in:
commit
8bc5679bcc
@ -109,6 +109,16 @@ final class AmpResponse implements ResponseInterface
|
|||||||
return null !== $type ? $this->info[$type] ?? null : $this->info;
|
return null !== $type ? $this->info[$type] ?? null : $this->info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function __sleep()
|
||||||
|
{
|
||||||
|
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __wakeup()
|
||||||
|
{
|
||||||
|
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
|
||||||
|
}
|
||||||
|
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
@ -63,6 +63,16 @@ class Connection
|
|||||||
$this->client = $client ?? new SqsClient([]);
|
$this->client = $client ?? new SqsClient([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function __sleep()
|
||||||
|
{
|
||||||
|
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __wakeup()
|
||||||
|
{
|
||||||
|
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
|
||||||
|
}
|
||||||
|
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
{
|
{
|
||||||
$this->reset();
|
$this->reset();
|
||||||
|
@ -359,6 +359,10 @@ class UnicodeString extends AbstractUnicodeString
|
|||||||
|
|
||||||
public function __wakeup()
|
public function __wakeup()
|
||||||
{
|
{
|
||||||
|
if (!\is_string($this->string)) {
|
||||||
|
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
|
||||||
|
}
|
||||||
|
|
||||||
normalizer_is_normalized($this->string) ?: $this->string = normalizer_normalize($this->string);
|
normalizer_is_normalized($this->string) ?: $this->string = normalizer_normalize($this->string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user