Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion adminer/drivers/mysql.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ function attach(string $server, string $username, string $password): string {
}
list($host, $port) = host_port($server);
return $this->dsn(
"mysql:charset=utf8;host=$host" . ($port ? (is_numeric($port) ? ";port=" : ";unix_socket=") . $port : ""),
"mysql:charset=utf8".(!empty($host) ? ";host=$host" : '') . ($port ? (is_numeric($port) ? ";port=" : ";unix_socket=") . $port : ""),
$username,
$password,
$options
Expand Down
2 changes: 1 addition & 1 deletion adminer/include/functions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ function is_shortable(array $field): bool {
function host_port(string $server) {
return (preg_match('~^(\[(.+)]|([^:]+)):([^:]+)$~', $server, $match) // [a:b] - IPv6
? array($match[2] . $match[3], $match[4])
: array($server, '')
: (preg_match('~^(\[(.+)]|([^:]+))$~', $server, $match) ? array($match[2] . $match[3], '') : explode(':', $server, 2)) // Match IPv6 or hostname without port, else split by first colon
);
}

Expand Down
Loading