Skip to content

IPv6 addresses in configuration is not parsed, and result in an error #9937

@rpc-scandinavia

Description

@rpc-scandinavia

Prerequisites

  • I have searched for duplicate or closed issues
  • I can recreate the issue with all plugins disabled

Describe the issue

I am testing the new RCM and configure SQL using an IPv6 address like [fd00:3::10], but RCM can't parse those and fails with the Oops screen.

This is configured in config.inc.php for SQL:

$config['db_dsnw'] = 'mysql://user:pass@[fd00:3::11]/roundcubemail';

And I think the error is with this code in /usr/local/lib/roundcubemail/program/lib/Roundcube/rcube_db.php in the parse_dsn method:

        // Find protocol and hostspec
        // $dsn => proto(proto_opts)/database
        if (preg_match('|^([^(]+)\((.*?)\)/?(.*?)$|', $dsn, $match)) {
            $proto = $match[1];
            $proto_opts = $match[2] ?: false;
            $dsn = $match[3];
        }
        // $dsn => protocol+hostspec/database (old format)
        else {
            if (strpos($dsn, '+') !== false) {
                [$proto, $dsn] = explode('+', $dsn, 2);
            }
            if (strpos($dsn, '/') !== false) {
                [$proto_opts, $dsn] = explode('/', $dsn, 2);
            } else {
                $proto_opts = $dsn;
                $dsn = null;
            }
        }

        // process the different protocol options
        $parsed['protocol'] = !empty($proto) ? $proto : 'tcp';
        $proto_opts = rawurldecode($proto_opts);
        if (strpos($proto_opts, ':') !== false) {
            [$proto_opts, $parsed['port']] = explode(':', $proto_opts);
        }
        if ($parsed['protocol'] == 'tcp' && strlen($proto_opts)) {
            $parsed['hostspec'] = $proto_opts;
        } elseif ($parsed['protocol'] == 'unix') {
            $parsed['socket'] = $proto_opts;
        }

It seems that IPv6 probably only fails with SQL.
I confirmed that it is okay in password.inc.php like:

$config['password_ldap_host'] = '[fd00:3::10]';

And in config.inc.php like:

$config['smtp_host'] = '[fd00:3::12]:25';

Perhaps the SQL address should be split up in several settings like:

$config['db_engine'] = 'mariadb';
$config['db_host'] = '[fd00:3::10]';
$config['db_port'] = 3306;
$config['db_user'] = 'user';
$config['db_pass'] = 'user';
$config['db_options'] = '';
$config['db_readwrite'] = true;

What browser(s) are you seeing the problem on?

Firefox

What version of PHP are you using?

8.4.10

What version of Roundcube are you using?

1.7 Beta

JavaScript errors

No response

PHP errors

[22-Jul-2025 23:17:23 +0000]: <9d1a9a92> DB Error: SQLSTATE[HY000] [2002] Failed to parse IPv6 address "[fd00:3" in /usr/local/lib/roundcubemail/program/lib/Roundcube/rcube_db.php on line 188 (GET /?_task=logout&_token=HOCGV5mlC8CryJ1mzYRBy9NWF0IM0tZy)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions