Bladeren bron

fix(DB): Sanitize `host` parameter for postgres databases when IPv6 address is passed

Doctrine is using `pg_connect` with the `host` parameter, this does not allow IPv6 addresses in URI notation.
So we need to extract the IP address and pass it directly

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
tags/v28.0.5rc1
Ferdinand Thiessen 2 maanden geleden
bovenliggende
commit
2cabc708fb
No account linked to committer's email address
2 gewijzigde bestanden met toevoegingen van 13 en 3 verwijderingen
  1. 3
    3
      config/config.sample.php
  2. 10
    0
      lib/private/DB/ConnectionFactory.php

+ 3
- 3
config/config.sample.php Bestand weergeven



/** /**
* Your host server name, for example ``localhost``, ``hostname``, * Your host server name, for example ``localhost``, ``hostname``,
* ``hostname.example.com``, or the IP address. To specify a port use
* ``hostname:####``; to specify a Unix socket use
* ``/path/to/directory/containing/socket`` e.g. ``/run/postgresql/``.
* ``hostname.example.com``, or the IP address.
* To specify a port use ``hostname:####``, for IPv6 addresses use the URI notation ``[ip]:port``.
* To specify a Unix socket use ``/path/to/directory/containing/socket``, e.g. ``/run/postgresql/``.
*/ */
'dbhost' => '', 'dbhost' => '',



+ 10
- 0
lib/private/DB/ConnectionFactory.php Bestand weergeven

$eventManager->addEventSubscriber( $eventManager->addEventSubscriber(
new SQLSessionInit("SET SESSION AUTOCOMMIT=1")); new SQLSessionInit("SET SESSION AUTOCOMMIT=1"));
break; break;

case 'oci': case 'oci':
$eventManager->addEventSubscriber(new OracleSessionInit); $eventManager->addEventSubscriber(new OracleSessionInit);
// the driverOptions are unused in dbal and need to be mapped to the parameters // the driverOptions are unused in dbal and need to be mapped to the parameters
unset($additionalConnectionParams['host']); unset($additionalConnectionParams['host']);
break; break;


case 'pgsql':
// pg_connect used by Doctrine DBAL does not support URI notation (enclosed in brackets)
$matches = [];
if (preg_match('/^\[([^\]]+)\]$/', $additionalConnectionParams['host'], $matches)) {
// Host variable carries a port or socket.
$additionalConnectionParams['host'] = $matches[1];
}
break;

case 'sqlite3': case 'sqlite3':
$journalMode = $additionalConnectionParams['sqlite.journal_mode']; $journalMode = $additionalConnectionParams['sqlite.journal_mode'];
$additionalConnectionParams['platform'] = new OCSqlitePlatform(); $additionalConnectionParams['platform'] = new OCSqlitePlatform();

Laden…
Annuleren
Opslaan