Skip to content

Commit

Permalink
URL-decode URL-style DSN
Browse files Browse the repository at this point in the history
  • Loading branch information
c960657 authored and Christian Schmidt committed Jan 15, 2017
1 parent 7963f13 commit 2dc4196
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/Doctrine/DBAL/DriverManager.php
Expand Up @@ -259,6 +259,8 @@ private static function parseDatabaseUrl(array $params)
throw new DBALException('Malformed parameter "url".');
}

$url = array_map('rawurldecode', $url);

// If we have a connection URL, we have to unset the default PDO instance connection parameter (if any)
// as we cannot merge connection details from the URL into the PDO instance (URL takes precedence).
unset($params['pdo']);
Expand Down
4 changes: 4 additions & 0 deletions tests/Doctrine/Tests/DBAL/DriverManagerTest.php
Expand Up @@ -199,6 +199,10 @@ public function databaseUrls()
'drizzle-pdo-mysql://foo:bar@localhost/baz',
array('user' => 'foo', 'password' => 'bar', 'host' => 'localhost', 'dbname' => 'baz', 'driver' => 'Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver'),
),
'simple URL with percent encoding' => array(
'mysql://foo%3A:bar%2F@localhost/baz+baz%40',
array('user' => 'foo:', 'password' => 'bar/', 'host' => 'localhost', 'dbname' => 'baz+baz@', 'driver' => 'Doctrine\DBAL\Driver\PDOMySQL\Driver'),
),

// DBAL-1234
'URL without scheme and without any driver information' => array(
Expand Down

0 comments on commit 2dc4196

Please sign in to comment.