Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.x] Fix ConfigurationUrlParser query decoding #33340

Merged
merged 1 commit into from
Jun 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/Illuminate/Support/ConfigurationUrlParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
}

Expand Down Expand Up @@ -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;
}

/**
Expand Down
11 changes: 11 additions & 0 deletions tests/Support/ConfigurationUrlParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
[
Expand Down