Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable12] Only allow colons in db host for IPv6 addresses #6774

Merged
merged 1 commit into from Oct 15, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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