mirror of
https://github.com/archtechx/tenancy.git
synced 2026-05-06 15:24:03 +00:00
Skip null parameters, throw for other non-string parameters
This commit is contained in:
parent
e8168eb0b9
commit
9611a05f35
1 changed files with 5 additions and 1 deletions
|
|
@ -67,13 +67,17 @@ trait ValidatesDatabaseParameters
|
||||||
$allowedCharacters ??= static::allowedParameterCharacters();
|
$allowedCharacters ??= static::allowedParameterCharacters();
|
||||||
|
|
||||||
foreach ((array) $parameters as $parameter) {
|
foreach ((array) $parameters as $parameter) {
|
||||||
if (! is_string($parameter)) {
|
if (is_null($parameter)) {
|
||||||
// Skip if there's nothing to validate
|
// Skip if there's nothing to validate
|
||||||
// (e.g. when $tenant->database()->getUsername() of an
|
// (e.g. when $tenant->database()->getUsername() of an
|
||||||
// improperly created tenant is null and it gets passed).
|
// improperly created tenant is null and it gets passed).
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! is_string($parameter)) {
|
||||||
|
throw new InvalidArgumentException("Parameter has to be a string.");
|
||||||
|
}
|
||||||
|
|
||||||
foreach (str_split($parameter) as $character) {
|
foreach (str_split($parameter) as $character) {
|
||||||
if (! str_contains($allowedCharacters, $character)) {
|
if (! str_contains($allowedCharacters, $character)) {
|
||||||
throw new InvalidArgumentException("Forbidden character '{$character}' in parameter.");
|
throw new InvalidArgumentException("Forbidden character '{$character}' in parameter.");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue