Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Dont allow unserializing classes with a destructor - 5.2
  • Loading branch information
jderusse committed Dec 15, 2020
commit 98601908bb727a3b40433da8b7500d392ff7ad24
10 changes: 10 additions & 0 deletions src/Symfony/Component/HttpClient/Response/CommonResponseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ public function toStream(bool $throw = true)
return $stream;
}

public function __sleep()
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}

/**
* Closes the response and all its network handles.
*/
Expand Down
10 changes: 10 additions & 0 deletions src/Symfony/Component/HttpClient/Response/TraceableResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ public function __construct(HttpClientInterface $client, ResponseInterface $resp
$this->event = $event;
}

public function __sleep()
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}

public function __destruct()
{
try {
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/RateLimiter/Policy/TokenBucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ public function __sleep(): array
*/
public function __wakeup(): void
{
if (!\is_string($this->stringRate)) {
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}

$this->rate = Rate::fromString($this->stringRate);
unset($this->stringRate);
}
Expand Down