aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2018-04-18 14:47:04 +0200
committerJoas Schilling <coding@schilljs.com>2018-04-18 14:48:21 +0200
commit8f7a0af9515a6441b692719310c3e02832d9de65 (patch)
treeca3e949d2b3081d1727107071a4826310b62333d /lib
parent63dfbb2127ec9a930778dd5d31b640c5f2cc3652 (diff)
downloadnextcloud-server-8f7a0af9515a6441b692719310c3e02832d9de65.tar.gz
nextcloud-server-8f7a0af9515a6441b692719310c3e02832d9de65.zip
Allow IPv6 database hosts
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/DB/ConnectionFactory.php13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/private/DB/ConnectionFactory.php b/lib/private/DB/ConnectionFactory.php
index c841a36bb5a..f5b8a9d3c2f 100644
--- a/lib/private/DB/ConnectionFactory.php
+++ b/lib/private/DB/ConnectionFactory.php
@@ -193,13 +193,14 @@ class ConnectionFactory {
$connectionParams['path'] = $dataDir . '/' . $name . '.db';
} else {
$host = $this->config->getValue('dbhost', '');
- if (strpos($host, ':')) {
- // Host variable may carry a port or socket.
- list($host, $portOrSocket) = explode(':', $host, 2);
- if (ctype_digit($portOrSocket)) {
- $connectionParams['port'] = $portOrSocket;
+ $matches = [];
+ if (preg_match('/^(.*):([^\]:]+)$/', $host, $matches)) {
+ // Host variable carries a port or socket.
+ $host = $matches[1];
+ if (is_numeric($matches[2])) {
+ $connectionParams['port'] = (int) $matches[2];
} else {
- $connectionParams['unix_socket'] = $portOrSocket;
+ $connectionParams['unix_socket'] = $matches[2];
}
}
$connectionParams['host'] = $host;