Skip to content

Commit 97de12b

Browse files
committed
Don't use parse_url for the schema validation (because it doesn't support underscores)
1 parent b8ef38a commit 97de12b

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎pkg/dbal/DbalConnectionFactory.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ private function parseDsn($dsn)
9898
throw new \LogicException(sprintf('Failed to parse DSN "%s"', $dsn));
9999
}
100100

101-
$schema = parse_url($dsn, PHP_URL_SCHEME);
102-
if (empty($schema)) {
101+
if (!preg_match('/^([0-9a-z_]+):(.+)?$/', $dsn, $matches)) {
103102
throw new \LogicException('Schema is empty');
104103
}
104+
$schema = $matches[1];
105105

106106
$supported = [
107107
'db2' => true,

‎pkg/dbal/Tests/DbalConnectionFactoryConfigTest.php‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ public static function provideConfigs()
7272
],
7373
];
7474

75+
yield [
76+
'pdo_mysql:',
77+
[
78+
'lazy' => true,
79+
'connection' => [
80+
'url' => 'pdo_mysql://root@localhost',
81+
],
82+
],
83+
];
84+
7585
yield [
7686
'pgsql:',
7787
[

0 commit comments

Comments
 (0)