Skip to content
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
20 changes: 20 additions & 0 deletions src/Symfony/Component/Mailer/Tests/Transport/DsnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,26 @@ public function fromStringProvider(): iterable
new Dsn('smtp', 'example.com'),
];

yield 'simple dsn including @ sign, but no user/password/token' => [
'scheme://@localhost',
new Dsn('scheme', 'localhost', null, null),
];

yield 'simple dsn including : sign and @ sign, but no user/password/token' => [
'scheme://:@localhost',
new Dsn('scheme', 'localhost', null, null),
];

yield 'simple dsn including user, : sign and @ sign, but no password' => [
'scheme://user1:@localhost',
new Dsn('scheme', 'localhost', 'user1', null),
];

yield 'simple dsn including : sign, password, and @ sign, but no user' => [
'scheme://:pass@localhost',
new Dsn('scheme', 'localhost', null, 'pass'),
];

yield 'simple smtp with custom port' => [
'smtp://user1:pass2@example.com:99',
new Dsn('smtp', 'example.com', 'user1', 'pass2', 99),
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Mailer/Transport/Dsn.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public static function fromString(string $dsn): self
throw new InvalidArgumentException(sprintf('The "%s" mailer DSN must contain a host (use "default" by default).', $dsn));
}

$user = isset($parsedDsn['user']) ? urldecode($parsedDsn['user']) : null;
$password = isset($parsedDsn['pass']) ? urldecode($parsedDsn['pass']) : null;
$user = '' !== ($parsedDsn['user'] ?? '') ? urldecode($parsedDsn['user']) : null;
$password = '' !== ($parsedDsn['pass'] ?? '') ? urldecode($parsedDsn['pass']) : null;
$port = $parsedDsn['port'] ?? null;
parse_str($parsedDsn['query'] ?? '', $query);

Expand Down