Skip to content

Commit 585ad66

Browse files
alexandre-dauboisnicolas-grekas
authored andcommitted
[Cache][DependencyInjection][Lock][Mailer][Messenger][Notifier][Translation] Url decode username and passwords from parse_url() results
1 parent 75d5681 commit 585ad66

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

EnvVarProcessor.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,15 +253,15 @@ public function getEnv(string $prefix, string $name, \Closure $getEnv)
253253
}
254254

255255
if ('url' === $prefix) {
256-
$parsedEnv = parse_url($env);
256+
$params = parse_url($env);
257257

258-
if (false === $parsedEnv) {
258+
if (false === $params) {
259259
throw new RuntimeException(sprintf('Invalid URL in env var "%s".', $name));
260260
}
261-
if (!isset($parsedEnv['scheme'], $parsedEnv['host'])) {
261+
if (!isset($params['scheme'], $params['host'])) {
262262
throw new RuntimeException(sprintf('Invalid URL env var "%s": schema and host expected, "%s" given.', $name, $env));
263263
}
264-
$parsedEnv += [
264+
$params += [
265265
'port' => null,
266266
'user' => null,
267267
'pass' => null,
@@ -270,10 +270,13 @@ public function getEnv(string $prefix, string $name, \Closure $getEnv)
270270
'fragment' => null,
271271
];
272272

273+
$params['user'] = null !== $params['user'] ? rawurldecode($params['user']) : null;
274+
$params['pass'] = null !== $params['pass'] ? rawurldecode($params['pass']) : null;
275+
273276
// remove the '/' separator
274-
$parsedEnv['path'] = '/' === ($parsedEnv['path'] ?? '/') ? '' : substr($parsedEnv['path'], 1);
277+
$params['path'] = '/' === ($params['path'] ?? '/') ? '' : substr($params['path'], 1);
275278

276-
return $parsedEnv;
279+
return $params;
277280
}
278281

279282
if ('query_string' === $prefix) {

0 commit comments

Comments
 (0)