Skip to content

Commit 955f7bd

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 0d2c0e0 commit 955f7bd

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Transport/Dsn.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,24 @@ public function __construct(string $scheme, string $host, string $user = null, s
3737

3838
public static function fromString(string $dsn): self
3939
{
40-
if (false === $parsedDsn = parse_url($dsn)) {
40+
if (false === $params = parse_url($dsn)) {
4141
throw new InvalidArgumentException('The mailer DSN is invalid.');
4242
}
4343

44-
if (!isset($parsedDsn['scheme'])) {
44+
if (!isset($params['scheme'])) {
4545
throw new InvalidArgumentException('The mailer DSN must contain a scheme.');
4646
}
4747

48-
if (!isset($parsedDsn['host'])) {
48+
if (!isset($params['host'])) {
4949
throw new InvalidArgumentException('The mailer DSN must contain a host (use "default" by default).');
5050
}
5151

52-
$user = '' !== ($parsedDsn['user'] ?? '') ? urldecode($parsedDsn['user']) : null;
53-
$password = '' !== ($parsedDsn['pass'] ?? '') ? urldecode($parsedDsn['pass']) : null;
54-
$port = $parsedDsn['port'] ?? null;
55-
parse_str($parsedDsn['query'] ?? '', $query);
52+
$user = '' !== ($params['user'] ?? '') ? rawurldecode($params['user']) : null;
53+
$password = '' !== ($params['pass'] ?? '') ? rawurldecode($params['pass']) : null;
54+
$port = $params['port'] ?? null;
55+
parse_str($params['query'] ?? '', $query);
5656

57-
return new self($parsedDsn['scheme'], $parsedDsn['host'], $user, $password, $port, $query);
57+
return new self($params['scheme'], $params['host'], $user, $password, $port, $query);
5858
}
5959

6060
public function getScheme(): string

0 commit comments

Comments
 (0)