Skip to content

Commit 7400e57

Browse files
committed
ConfigurationUrlParser: fix query decoding
1 parent 6cbb1ff commit 7400e57

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

src/Illuminate/Support/ConfigurationUrlParser.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,15 @@ public function parseConfiguration($config)
3939
return $config;
4040
}
4141

42-
$parsedUrl = $this->parseUrl($url);
42+
$rawComponents = $this->parseUrl($url);
43+
$decodedComponents = $this->parseStringsToNativeTypes(
44+
array_map('rawurldecode', $rawComponents)
45+
);
4346

4447
return array_merge(
4548
$config,
46-
$this->getPrimaryOptions($parsedUrl),
47-
$this->getQueryOptions($parsedUrl)
49+
$this->getPrimaryOptions($decodedComponents),
50+
$this->getQueryOptions($rawComponents)
4851
);
4952
}
5053

@@ -137,9 +140,7 @@ protected function parseUrl($url)
137140
throw new InvalidArgumentException('The database configuration URL is malformed.');
138141
}
139142

140-
return $this->parseStringsToNativeTypes(
141-
array_map('rawurldecode', $parsedUrl)
142-
);
143+
return $parsedUrl;
143144
}
144145

145146
/**

tests/Support/ConfigurationUrlParserTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,17 @@ public function databaseUrls()
174174
'driver' => 'mysql',
175175
],
176176
],
177+
'simple URL with percent encoding in query' => [
178+
'mysql://foo:bar%25bar@localhost/baz?timezone=%2B00%3A00',
179+
[
180+
'username' => 'foo',
181+
'password' => 'bar%bar',
182+
'host' => 'localhost',
183+
'database' => 'baz',
184+
'driver' => 'mysql',
185+
'timezone' => '+00:00',
186+
],
187+
],
177188
'URL with mssql alias driver' => [
178189
'mssql://null',
179190
[

0 commit comments

Comments
 (0)