Only allow colons in db host for IPv6 addresses

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2017-09-26 14:20:04 +02:00
parent 037376b4ce
commit 8f41e8ee60
No known key found for this signature in database
GPG Key ID: E166FD8976B3BAC8
1 changed files with 16 additions and 0 deletions

View File

@ -294,6 +294,10 @@ class Setup {
$error[] = $l->t("Can't create or write into the data directory %s", array($dataDir));
}
if (!$this->validateDatabaseHost($options['dbhost'])) {
$error[] = $l->t('Given database host is invalid and must not contain the port: %s', [$options['dbhost']]);
}
if(count($error) != 0) {
return $error;
}
@ -409,6 +413,18 @@ class Setup {
return $error;
}
/**
* @param string $host
* @return bool
*/
protected function validateDatabaseHost($host) {
if (strpos($host, ':') === false) {
return true;
}
return filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false;
}
public static function installBackgroundJobs() {
\OC::$server->getJobList()->add('\OC\Authentication\Token\DefaultTokenCleanupJob');
}