Skip to content
Snippets Groups Projects
Commit 04670060 authored by Al Munnings's avatar Al Munnings
Browse files

Throw to be safer

parent 968bc36c
No related branches found
No related tags found
No related merge requests found
Pipeline #141253 passed
......@@ -37,7 +37,11 @@ class DatabaseStorageExpirableToken extends DatabaseStorageExpirable {
$token = preg_replace('/[^a-z0-9_-]/i', '', $token);
$token = trim($token);
return empty($token) ? '' : sprintf('%%;s:13:"preview_token";s:%d:"%s";%%', strlen($token), $token);
if (empty($token)) {
throw new \InvalidArgumentException('Invalid token value.');
}
return sprintf('%%;s:13:"preview_token";s:%d:"%s";%%', strlen($token), $token);
}
/**
......@@ -51,7 +55,6 @@ class DatabaseStorageExpirableToken extends DatabaseStorageExpirable {
*/
public function getKeyByToken(?string $token) {
try {
// Search for the token.
$data = $this->connection->query(
'SELECT [name], [value] FROM {' . $this->connection->escapeTable($this->table) . '} WHERE value LIKE :token AND collection = :collection',
[
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment