Skip to content

Commit

Permalink
Merge pull request #6774 from nextcloud/backport-6645-only-colons-for…
Browse files Browse the repository at this point in the history
…-ipv6

[stable12] Only allow colons in db host for IPv6 addresses
  • Loading branch information
rullzer committed Oct 15, 2017
2 parents 95bd9d4 + 8f41e8e commit 6e3ec7d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/private/Setup.php
Expand Up @@ -294,6 +294,10 @@ public function install($options) {
$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;
}
Expand Down Expand Up @@ -409,6 +413,18 @@ public function install($options) {
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');
}
Expand Down

0 comments on commit 6e3ec7d

Please sign in to comment.