From 98ea3a51fb604fc439dbf6b9618cb858229549e6 Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Sun, 31 Dec 2023 10:34:28 +0100 Subject: [PATCH] [Cache][DependencyInjection][Lock][Mailer][Messenger][Notifier][Translation] Url decode username and passwords from `parse_url()` results --- Transport/Dsn.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Transport/Dsn.php b/Transport/Dsn.php index 6f4c357..667b7f8 100644 --- a/Transport/Dsn.php +++ b/Transport/Dsn.php @@ -33,25 +33,25 @@ public function __construct(string $dsn) { $this->originalDsn = $dsn; - if (false === $parsedDsn = parse_url($dsn)) { + if (false === $params = parse_url($dsn)) { throw new InvalidArgumentException('The notifier DSN is invalid.'); } - if (!isset($parsedDsn['scheme'])) { + if (!isset($params['scheme'])) { throw new InvalidArgumentException('The notifier DSN must contain a scheme.'); } - $this->scheme = $parsedDsn['scheme']; + $this->scheme = $params['scheme']; - if (!isset($parsedDsn['host'])) { + if (!isset($params['host'])) { throw new InvalidArgumentException('The notifier DSN must contain a host (use "default" by default).'); } - $this->host = $parsedDsn['host']; + $this->host = $params['host']; - $this->user = '' !== ($parsedDsn['user'] ?? '') ? urldecode($parsedDsn['user']) : null; - $this->password = '' !== ($parsedDsn['pass'] ?? '') ? urldecode($parsedDsn['pass']) : null; - $this->port = $parsedDsn['port'] ?? null; - $this->path = $parsedDsn['path'] ?? null; - parse_str($parsedDsn['query'] ?? '', $this->options); + $this->user = '' !== ($params['user'] ?? '') ? rawurldecode($params['user']) : null; + $this->password = '' !== ($params['pass'] ?? '') ? rawurldecode($params['pass']) : null; + $this->port = $params['port'] ?? null; + $this->path = $params['path'] ?? null; + parse_str($params['query'] ?? '', $this->options); } public function getScheme(): string