Dont allow unserializing classes with a destructor - 5.1

This commit is contained in:
Jérémy Derussé 2020-12-12 17:30:27 +01:00
parent 7c7366a82a
commit 07402f4af3
No known key found for this signature in database
GPG Key ID: 2083FA5758C473D2
3 changed files with 24 additions and 0 deletions

View File

@ -109,6 +109,16 @@ final class AmpResponse implements ResponseInterface
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()
{
try {

View File

@ -63,6 +63,16 @@ class Connection
$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()
{
$this->reset();

View File

@ -359,6 +359,10 @@ class UnicodeString extends AbstractUnicodeString
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);
}