diff --git a/src/Illuminate/Support/ConfigurationUrlParser.php b/src/Illuminate/Support/ConfigurationUrlParser.php index e67e469ed15e..4a036b80e98c 100644 --- a/src/Illuminate/Support/ConfigurationUrlParser.php +++ b/src/Illuminate/Support/ConfigurationUrlParser.php @@ -39,12 +39,15 @@ public function parseConfiguration($config) return $config; } - $parsedUrl = $this->parseUrl($url); + $rawComponents = $this->parseUrl($url); + $decodedComponents = $this->parseStringsToNativeTypes( + array_map('rawurldecode', $rawComponents) + ); return array_merge( $config, - $this->getPrimaryOptions($parsedUrl), - $this->getQueryOptions($parsedUrl) + $this->getPrimaryOptions($decodedComponents), + $this->getQueryOptions($rawComponents) ); } @@ -137,9 +140,7 @@ protected function parseUrl($url) throw new InvalidArgumentException('The database configuration URL is malformed.'); } - return $this->parseStringsToNativeTypes( - array_map('rawurldecode', $parsedUrl) - ); + return $parsedUrl; } /** diff --git a/tests/Support/ConfigurationUrlParserTest.php b/tests/Support/ConfigurationUrlParserTest.php index 4e6439d4a164..5a23513f5b5b 100644 --- a/tests/Support/ConfigurationUrlParserTest.php +++ b/tests/Support/ConfigurationUrlParserTest.php @@ -174,6 +174,17 @@ public function databaseUrls() 'driver' => 'mysql', ], ], + 'simple URL with percent encoding in query' => [ + 'mysql://foo:bar%25bar@localhost/baz?timezone=%2B00%3A00', + [ + 'username' => 'foo', + 'password' => 'bar%bar', + 'host' => 'localhost', + 'database' => 'baz', + 'driver' => 'mysql', + 'timezone' => '+00:00', + ], + ], 'URL with mssql alias driver' => [ 'mssql://null', [