summaryrefslogtreecommitdiffstats
path: root/lib/private/Setup.php
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-09-26 14:20:04 +0200
committerJoas Schilling <coding@schilljs.com>2017-09-26 14:20:04 +0200
commit1287d6ddb303fc9b088b8a6837490042a1540dc6 (patch)
tree2d684cde91930ea6f8daac2fadf3cee3227566e1 /lib/private/Setup.php
parentef3e8faea22a3a7278dbf24f3988c80d80415090 (diff)
downloadnextcloud-server-1287d6ddb303fc9b088b8a6837490042a1540dc6.tar.gz
nextcloud-server-1287d6ddb303fc9b088b8a6837490042a1540dc6.zip
Only allow colons in db host for IPv6 addresses
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Setup.php')
-rw-r--r--lib/private/Setup.php16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/private/Setup.php b/lib/private/Setup.php
index 521a8f75f8e..6cef1eb861d 100644
--- a/lib/private/Setup.php
+++ b/lib/private/Setup.php
@@ -293,6 +293,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;
}
@@ -410,6 +414,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');
}