Skip to content

Commit 21a1fc0

Browse files
committed
Fix GH-20528: Regression breaks mysql connexion using an IPv6 address enclosed in square brackets
1 parent 8c24077 commit 21a1fc0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ext/mysqlnd/mysqlnd_connection.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,10 +557,11 @@ MYSQLND_METHOD(mysqlnd_conn_data, get_scheme)(MYSQLND_CONN_DATA * conn, MYSQLND_
557557
if (hostname.s[0] != '[' && mysqlnd_fast_is_ipv6_address(hostname.s)) {
558558
transport.l = mnd_sprintf(&transport.s, 0, "tcp://[%s]:%u", hostname.s, port);
559559
} else {
560-
/* Not ipv6, but could already contain a port number, in which case we should not add an extra port.
560+
/* Could already contain a port number, in which case we should not add an extra port.
561561
* See GH-8978. In a port doubling scenario, the first port would be used so we do the same to keep BC. */
562-
if (strchr(hostname.s, ':')) {
562+
if (strchr(hostname.s, ':') && !mysqlnd_fast_is_ipv6_address(hostname.s)) {
563563
/* TODO: Ideally we should be able to get rid of this workaround in the future. */
564+
/* TODO: IPv6 address enclosed in square brackets is not handled, ex [::1]:3306 */
564565
transport.l = mnd_sprintf(&transport.s, 0, "tcp://%s", hostname.s);
565566
} else {
566567
transport.l = mnd_sprintf(&transport.s, 0, "tcp://%s:%u", hostname.s, port);

0 commit comments

Comments
 (0)