Fix _APP_CONSOLE_HOSTNAMES check
Ensure invalid hostnames such as empty strings are not added as a hostname.
This commit is contained in:
parent
06e385b346
commit
faf39fcc81
1 changed files with 12 additions and 8 deletions
20
app/init.php
20
app/init.php
|
@ -80,6 +80,7 @@ use Utopia\Queue\Connection;
|
||||||
use Utopia\Storage\Storage;
|
use Utopia\Storage\Storage;
|
||||||
use Utopia\VCS\Adapter\Git\GitHub as VcsGitHub;
|
use Utopia\VCS\Adapter\Git\GitHub as VcsGitHub;
|
||||||
use Utopia\Validator\Range;
|
use Utopia\Validator\Range;
|
||||||
|
use Utopia\Validator\Hostname;
|
||||||
use Utopia\Validator\IP;
|
use Utopia\Validator\IP;
|
||||||
use Utopia\Validator\URL;
|
use Utopia\Validator\URL;
|
||||||
use Utopia\Validator\WhiteList;
|
use Utopia\Validator\WhiteList;
|
||||||
|
@ -947,15 +948,18 @@ App::setResource('clients', function ($request, $console, $project) {
|
||||||
], Document::SET_TYPE_APPEND);
|
], Document::SET_TYPE_APPEND);
|
||||||
|
|
||||||
$hostnames = explode(',', App::getEnv('_APP_CONSOLE_HOSTNAMES', ''));
|
$hostnames = explode(',', App::getEnv('_APP_CONSOLE_HOSTNAMES', ''));
|
||||||
if (is_array($hostnames)) {
|
$validator = new Hostname();
|
||||||
foreach ($hostnames as $hostname) {
|
foreach ($hostnames as $hostname) {
|
||||||
$console->setAttribute('platforms', [
|
$hostname = trim($hostname);
|
||||||
'$collection' => ID::custom('platforms'),
|
if (!$validator->isValid($hostname)) {
|
||||||
'type' => Origin::CLIENT_TYPE_WEB,
|
continue;
|
||||||
'name' => $hostname,
|
|
||||||
'hostname' => $hostname,
|
|
||||||
], Document::SET_TYPE_APPEND);
|
|
||||||
}
|
}
|
||||||
|
$console->setAttribute('platforms', [
|
||||||
|
'$collection' => ID::custom('platforms'),
|
||||||
|
'type' => Origin::CLIENT_TYPE_WEB,
|
||||||
|
'name' => $hostname,
|
||||||
|
'hostname' => $hostname,
|
||||||
|
], Document::SET_TYPE_APPEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue