8000 Merge branch '5.4' into 6.3 · kzorluoglu/symfony@11b54e6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 11b54e6

Browse files
Merge branch '5.4' into 6.3
* 5.4: append instead of replacing potentially non-existent named-arguments [Validator] added missing Polish translation add translations for the MacAddress constraint remove invalid changelog entry Added missing Serbian (sr_Latn) translations [Cache][DependencyInjection][Lock][Mailer][Messenger][Notifier][Translation] Url decode username and passwords from `parse_url()` results [Security] added missing Albanian translations [Validator] Add missing Hungarian translation [Serializer] Fix using deserialization path [Validator] Add missing hr translation
2 parents e6653f2 + bf62cbe commit 11b54e6

File tree

23 files changed

+209
-109
lines changed

23 files changed

+209
-109
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2811,27 +2811,27 @@ private function registerNotifierConfiguration(array $config, ContainerBuilder $
28112811

28122812
if (ContainerBuilder::willBeAvailable('symfony/mercure-notifier', NotifierBridge\Mercure\MercureTransportFactory::class, $parentPackages) && ContainerBuilder::willBeAvailable('symfony/mercure-bundle', MercureBundle::class, $parentPackages) && \in_array(MercureBundle::class, $container->getParameter('kernel.bundles'), true)) {
28132813
$container->getDefinition($classToServices[NotifierBridge\Mercure\MercureTransportFactory::class])
2814-
->replaceArgument('$registry', new Reference(HubRegistry::class))
2815-
->replaceArgument('$client', new Reference('http_client', ContainerBuilder::NULL_ON_INVALID_REFERENCE))
2816-
->replaceArgument('$dispatcher', new Reference('event_dispatcher', ContainerBuilder::NULL_ON_INVALID_REFERENCE));
2814+
->replaceArgument(0, new Reference(HubRegistry::class))
2815+
->replaceArgument(1, new Reference('event_dispatcher', ContainerBuilder::NULL_ON_INVALID_REFERENCE))
2816+
->addArgument(new Reference('http_client', ContainerBuilder::NULL_ON_INVALID_REFERENCE));
28172817
} elseif (ContainerBuilder::willBeAvailable('symfony/mercure-notifier', NotifierBridge\Mercure\MercureTransportFactory::class, $parentPackages)) {
28182818
$container->removeDefinition($classToServices[NotifierBridge\Mercure\MercureTransportFactory::class]);
28192819
}
28202820

28212821
if (ContainerBuilder::willBeAvailable('symfony/fake-chat-notifier', NotifierBridge\FakeChat\FakeChatTransportFactory::class, ['symfony/framework-bundle', 'symfony/notifier', 'symfony/mailer'])) {
28222822
$container->getDefinition($classToServices[NotifierBridge\FakeChat\FakeChatTransportFactory::class])
2823-
->replaceArgument('$mailer', new Reference('mailer'))
2824-
->replaceArgument('$logger', new Reference('logger'))
2825-
->replaceArgument('$client', new Reference('http_client', ContainerBuilder::NULL_ON_INVALID_REFERENCE))
2826-
->replaceArgument('$dispatcher', new Reference('event_dispatcher', ContainerBuilder::NULL_ON_INVALID_REFERENCE));
2823+
->replaceArgument(0, new Reference('mailer'))
2824+
->replaceArgument(1, new Reference('logger'))
2825+
->addArgument(new Reference('event_dispatcher', ContainerBuilder::NULL_ON_INVALID_REFERENCE))
2826+
->addArgument(new Reference('http_client', ContainerBuilder::NULL_ON_INVALID_REFERENCE));
28272827
}
28282828

28292829
if (ContainerBuilder::willBeAvailable('symfony/fake-sms-notifier', NotifierBridge\FakeSms\FakeSmsTransportFactory::class, ['symfony/framework-bundle', 'symfony/notifier', 'symfony/mailer'])) {
28302830
$container->getDefinition($classToServices[NotifierBridge\FakeSms\FakeSmsTransportFactory::class])
2831-
->replaceArgument('$mailer', new Reference('mailer'))
2832-
->replaceArgument('$logger', new Reference('logger'))
2833-
->replaceArgument('$client', new Reference('http_client', ContainerBuilder::NULL_ON_INVALID_REFERENCE))
2834-
->replaceArgument('$dispatcher', new Reference('event_dispatcher', ContainerBuilder::NULL_ON_INVALID_REFERENCE));
2831+
->replaceArgument(0, new Reference('mailer'))
2832+
->replaceArgument(1, new Reference('logger'))
2833+
->addArgument(new Reference('event_dispatcher', ContainerBuilder::NULL_ON_INVALID_REFERENCE))
2834+
->addArgument(new Reference('http_client', ContainerBuilder::NULL_ON_INVALID_REFERENCE));
28352835
}
28362836

28372837
if (isset($config['admin_recipients'])) {

src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ public static function createConnection(#[\SensitiveParameter] array|string $ser
113113
$params = preg_replace_callback('#^memcached:(//)?(?:([^@]*+)@)?#', function ($m) use (&$username, &$password) {
114114
if (!empty($m[2])) {
115115
[$username, $password] = explode(':', $m[2], 2) + [1 => null];
116+
$username = rawurldecode($username);
117+
$password = null !== $password ? rawurldecode($password) : null;
116118
}
117119

118120
return 'file:'.($m[1] ?? '');

src/Symfony/Component/DependencyInjection/EnvVarProcessor.php

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

276276
if ('url' === $prefix) {
277-
$parsedEnv = parse_url($env);
277+
$params = parse_url($env);
278278

279-
if (false === $parsedEnv) {
279+
if (false === $params) {
280280
throw new RuntimeException(sprintf('Invalid URL in env var "%s".', $name));
281281
}
282-
if (!isset($parsedEnv['scheme'], $parsedEnv['host'])) {
282+
if (!isset($params['scheme'], $params['host'])) {
283283
throw new RuntimeException(sprintf('Invalid URL env var "%s": schema and host expected, "%s" given.', $name, $env));
284284
}
285-
$parsedEnv += [
285+
$params += [
286286
'port' => null,
287287
'user' => null,
288288
'pass' => null,
@@ -291,10 +291,13 @@ public function getEnv(string $prefix, string $name, \Closure $getEnv): mixed
291291
'fragment' => null,
292292
];
293293

294+
$params['user'] = null !== $params['user'] ? rawurldecode($params['user']) : null;
295+
$params['pass'] = null !== $params['pass'] ? rawurldecode($params['pass']) : null;
296+
294297
// remove the '/' separator
295-
$parsedEnv['path'] = '/' === ($parsedEnv['path'] ?? '/') ? '' : substr($parsedEnv['path'], 1);
298+
$params['path'] = '/' === ($params['path'] ?? '/') ? '' : substr($params['path'], 1);
296299

297-
return $parsedEnv;
300+
return $params;
298301
}
299302

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

src/Symfony/Component/Lock/Store/MongoDbStore.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,10 @@ public function __construct(Collection|Client|string $mongo, array $options = []
142142
*/
143143
private function skimUri(string $uri): string
144144
{
145-
if (false === $parsedUrl = parse_url($uri)) {
145+
if (false === $params = parse_url($uri)) {
146146
throw new InvalidArgumentException(sprintf('The given MongoDB Connection URI "%s" is invalid.', $uri));
147147
}
148-
$pathDb = ltrim($parsedUrl['path'] ?? '', '/') ?: null;
148+
$pathDb = ltrim($params['path'] ?? '', '/') ?: null;
149149
if (null !== $pathDb) {
150150
$this->options['database'] = $pathDb;
151151
}

src/Symfony/Component/Mailer/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, #
3737

3838
public static function fromString(#[\SensitiveParameter] 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

src/Symfony/Component/Messenger/Bridge/AmazonSqs/Transport/Connection.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ public function __destruct()
102102
*/
103103
public static function fromDsn(#[\SensitiveParameter] string $dsn, array $options = [], HttpClientInterface $client = null, LoggerInterface $logger = null): self
104104
{
105-
if (false === $parsedUrl = parse_url($dsn)) {
105+
if (false === $params = parse_url($dsn)) {
106106
throw new InvalidArgumentException('The given Amazon SQS DSN is invalid.');
107107
}
108108

109109
$query = [];
110-
if (isset($parsedUrl['query'])) {
111-
parse_str($parsedUrl['query'], $query);
110+
if (isset($params['query'])) {
111+
parse_str($params['query'], $query);
112112
}
113113

114114
// check for extra keys in options
@@ -135,8 +135,8 @@ public static function fromDsn(#[\SensitiveParameter] string $dsn, array $option
135135

136136
$clientConfiguration = [
137137
'region' => $options['region'],
138-
'accessKeyId' => urldecode($parsedUrl['user'] ?? '') ?: $options['access_key'] ?? self::DEFAULT_OPTIONS['access_key'],
139-
'accessKeySecret' => urldecode($parsedUrl['pass'] ?? '') ?: $options['secret_key'] ?? self::DEFAULT_OPTIONS['secret_key'],
138+
'accessKeyId' => rawurldecode($params['user'] ?? '') ?: $options['access_key'] ?? self::DEFAULT_OPTIONS['access_key'],
139+
'accessKeySecret' => rawurldecode($params['pass'] ?? '') ?: $options['secret_key'] ?? self::DEFAULT_OPTIONS['secret_key'],
140140
];
141141
if (null !== $options['session_token']) {
142142
$clientConfiguration['sessionToken'] = $options['session_token'];
@@ -146,16 +146,16 @@ public static function fromDsn(#[\SensitiveParameter] string $dsn, array $option
146146
}
147147
unset($query['region']);
148148

149-
if ('default' !== ($parsedUrl['host'] ?? 'default')) {
150-
$clientConfiguration['endpoint'] = sprintf('%s://%s%s', ($query['sslmode'] ?? null) === 'disable' ? 'http' : 'https', $parsedUrl['host'], ($parsedUrl['port'] ?? null) ? ':'.$parsedUrl['port'] : '');
151-
if (preg_match(';^sqs\.([^\.]++)\.amazonaws\.com$;', $parsedUrl['host'], $matches)) {
149+
if ('default' !== ($params['host'] ?? 'default')) {
150+
$clientConfiguration['endpoint'] = sprintf('%s://%s%s', ($query['sslmode'] ?? null) === 'disable' ? 'http' : 'https', $params['host'], ($params['port'] ?? null) ? ':'.$params['port'] : '');
151+
if (preg_match(';^sqs\.([^\.]++)\.amazonaws\.com$;', $params['host'], $matches)) {
152152
$clientConfiguration['region'] = $matches[1];
153153
}
154154
} elseif (self::DEFAULT_OPTIONS['endpoint'] !== $options['endpoint'] ?? self::DEFAULT_OPTIONS['endpoint']) {
155155
$clientConfiguration['endpoint'] = $options['endpoint'];
156156
}
157157

158-
$parsedPath = explode('/', ltrim($parsedUrl['path'] ?? '/', '/'));
158+
$parsedPath = explode('/', ltrim($params['path'] ?? '/', '/'));
159159
if (\count($parsedPath) > 0 && !empty($queueName = end($parsedPath))) {
160160
$configuration['queue_name'] = $queueName;
161161
}
@@ -165,11 +165,11 @@ public static function fromDsn(#[\SensitiveParameter] string $dsn, array $option
165165
// https://sqs.REGION.amazonaws.com/ACCOUNT/QUEUE
166166
$queueUrl = null;
167167
if (
168-
'https' === $parsedUrl['scheme']
169-
&& ($parsedUrl['host'] ?? 'default') === "sqs.{$clientConfiguration['region']}.amazonaws.com"
170-
&& ($parsedUrl['path'] ?? '/') === "/{$configuration['account']}/{$configuration['queue_name']}"
168+
'https' === $params['scheme']
169+
&& ($params['host'] ?? 'default') === "sqs.{$clientConfiguration['region']}.amazonaws.com"
170+
&& ($params['path'] ?? '/') === "/{$configuration['account']}/{$configuration['queue_name']}"
171171
) {
172-
$queueUrl = 'https://'.$parsedUrl['host'].$parsedUrl['path'];
172+
$queueUrl = 'https://'.$params['host'].$params['path'];
173173
}
174174

175175
return new self($configuration, new SqsClient($clientConfiguration, null, $client, $logger), $queueUrl);

src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,24 +162,24 @@ public function __construct(array $connectionOptions, array $exchangeOptions, ar
162162
*/
163163
public static function fromDsn(#[\SensitiveParameter] string $dsn, array $options = [], AmqpFactory $amqpFactory = null): self
164164
{
165-
if (false === $parsedUrl = parse_url($dsn)) {
165+
if (false === $params = parse_url($dsn)) {
166166
// this is a valid URI that parse_url cannot handle when you want to pass all parameters as options
167167
if (!\in_array($dsn, ['amqp://', 'amqps://'])) {
168168
throw new InvalidArgumentException('The given AMQP DSN is invalid.');
169169
}
170170

171-
$parsedUrl = [];
171+
$params = [];
172172
}
173173

174174
$useAmqps = str_starts_with($dsn, 'amqps://');
175-
$pathParts = isset($parsedUrl['path']) ? explode('/', trim($parsedUrl['path'], '/')) : [];
175+
$pathParts = isset($params['path']) ? explode('/', trim($params['path'], '/')) : [];
176176
$exchangeName = $pathParts[1] ?? 'messages';
177-
parse_str($parsedUrl['query'] ?? '', $parsedQuery);
177+
parse_str($params['query'] ?? '', $parsedQuery);
178178
$port = $useAmqps ? 5671 : 5672;
179179

180180
$amqpOptions = array_replace_recursive([
181-
'host' => $parsedUrl['host'] ?? 'localhost',
182-
'port' => $parsedUrl['port'] ?? $port,
181+
'host' => $params['host'] ?? 'localhost',
182+
'port' => $params['port'] ?? $port,
183183
'vhost' => isset($pathParts[0]) ? urldecode($pathParts[0]) : '/',
184184
'exchange' => [
185185
'name' => $exchangeName,
@@ -188,12 +188,12 @@ p 58E8 ublic static function fromDsn(#[\SensitiveParameter] string $dsn, array $option
188188

189189
self::validateOptions($amqpOptions);
190190

191-
if (isset($parsedUrl['user'])) {
192-
$amqpOptions['login'] = urldecode($parsedUrl['user']);
191+
if (isset($params['user'])) {
192+
$amqpOptions['login'] = rawurldecode($params['user']);
193193
}
194194

195-
if (isset($parsedUrl['pass'])) {
196-
$amqpOptions['password'] = urldecode($parsedUrl['pass']);
195+
if (isset($params['pass'])) {
196+
$amqpOptions['password'] = rawurldecode($params['pass']);
197197
}
198198

199199
if (!isset($amqpOptions['queues'])) {

src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,16 @@ public function getConfiguration(): array
8787

8888
public static function buildConfiguration(#[\SensitiveParameter] string $dsn, array $options = []): array
8989
{
90-
if (false === $components = parse_url($dsn)) {
90+
if (false === $params = parse_url($dsn)) {
9191
throw new InvalidArgumentException('The given Doctrine Messenger DSN is invalid.');
9292
}
9393

9494
$query = [];
95-
if (isset($components['query'])) {
96-
parse_str($components['query'], $query);
95+
if (isset($params['query'])) {
96+
parse_str($params['query'], $query);
9797
}
9898

99-
$configuration = ['connection' => $components['host']];
99+
$configuration = ['connection' => $params['host']];
100100
$configuration += $query + $options + static::DEFAULT_OPTIONS;
101101

102102
$configuration['auto_setup'] = filter_var($configuration['auto_setup'], \FILTER_VALIDATE_BOOL);

src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -181,32 +181,32 @@ private static function initializeRedisCluster(?\RedisCluster $redis, array $hos
181181
public static function fromDsn(#[\SensitiveParameter] string $dsn, array $options = [], \Redis|Relay|\RedisCluster $redis = null): self
182182
{
183183
if (!str_contains($dsn, ',')) {
184-
$parsedUrl = self::parseDsn($dsn, $options);
184+
$params = self::parseDsn($dsn, $options);
185185

186-
if (isset($parsedUrl['host']) && 'rediss' === $parsedUrl['scheme']) {
187-
$parsedUrl['host'] = 'tls://'.$parsedUrl['host'];
186+
if (isset($params['host']) && 'rediss' === $params['scheme']) {
187+
$params['host'] = 'tls://'.$params['host'];
188188
}
189189
} else {
190190
$dsns = explode(',', $dsn);
191-
$parsedUrls = array_map(function ($dsn) use (&$options) {
191+
$paramss = array_map(function ($dsn) use (&$options) {
192192
return self::parseDsn($dsn, $options);
193193
}, $dsns);
194194

195195
// Merge all the URLs, the last one overrides the previous ones
196-
$parsedUrl = array_merge(...$parsedUrls);
197-
$tls = 'rediss' === $parsedUrl['scheme'];
196+
$params = array_merge(...$paramss);
197+
$tls = 'rediss' === $params['scheme'];
198198

199199
// Regroup all the hosts in an array interpretable by RedisCluster
200-
$parsedUrl['host'] = array_map(function ($parsedUrl) use ($tls) {
201-
if (!isset($parsedUrl['host'])) {
200+
$params['host'] = array_map(function ($params) use ($tls) {
201+
if (!isset($params['host'])) {
202202
throw new InvalidArgumentException('Missing host in DSN, it must be defined when using Redis Cluster.');
203203
}
204204
if ($tls) {
205-
$parsedUrl['host'] = 'tls://'.$parsedUrl['host'];
205+
$params['host'] = 'tls://'.$params['host'];
206206
}
207207

208-
return $parsedUrl['host'].':'.($parsedUrl['port'] ?? 6379);
209-
}, $parsedUrls, $dsns);
208+
return $params['host'].':'.($params['port'] ?? 6379);
209+
}, $paramss, $dsns);
210210
}
211211

212212
if ($invalidOptions = array_diff(array_keys($options), array_keys(self::DEFAULT_OPTIONS), ['host', 'port'])) {
@@ -221,20 +221,20 @@ public static function fromDsn(#[\SensitiveParameter] string $dsn, array $option
221221
};
222222
}
223223

224-
$pass = '' !== ($parsedUrl['pass'] ?? '') ? urldecode($parsedUrl['pass']) : null;
225-
$user = '' !== ($parsedUrl['user'] ?? '') ? urldecode($parsedUrl['user']) : null;
224+
$pass = '' !== ($params['pass'] ?? '') ? rawurldecode($params['pass']) : null;
225+
$user = '' !== ($params['user'] ?? '') ? rawurldecode($params['user']) : null;
226226
$options['auth'] ??= null !== $pass && null !== $user ? [$user, $pass] : ($pass ?? $user);
227227

228-
if (isset($parsedUrl['host'])) {
229-
$options['host'] = $parsedUrl['host'] ?? $options['host'];
230-
$options['port'] = $parsedUrl['port'] ?? $options['port'];
228+
if (isset($params['host'])) {
229+
$options['host'] = $params['host'] ?? $options['host'];
230+
$options['port'] = $params['port'] ?? $options['port'];
231231

232-
$pathParts = explode('/', rtrim($parsedUrl['path'] ?? '', '/'));
232+
$pathParts = explode('/', rtrim($params['path'] ?? '', '/'));
233233
$options['stream'] = $pathParts[1] ?? $options['stream'];
234234
$options['group'] = $pathParts[2] ?? $options['group'];
235235
$options['consumer'] = $pathParts[3] ?? $options['consumer'];
236236
} else {
237-
$options['host'] = $parsedUrl['path'];
237+
$options['host'] = $params['path'];
238238
$options['port'] = 0;
239239
}
240240

@@ -262,22 +262,22 @@ private static function parseDsn(string $dsn, array &$options): array
262262
return 'file:'.($m[1] ?? '');
263263
}, $url);
264264

265-
if (false === $parsedUrl = parse_url($url)) {
265+
if (false === $params = parse_url($url)) {
266266
throw new InvalidArgumentException('The given Redis DSN is invalid.');
267267
}
268268

269269
if (null !== $auth) {
270-
unset($parsedUrl['user']); // parse_url thinks //0@localhost/ is a username of "0"! doh!
271-
$parsedUrl += ($auth ?? []); // But don't worry as $auth array will have user, user/pass or pass as needed
270+
unset($params['user']); // parse_url thinks //0@localhost/ is a username of "0"! doh!
271+
$params += ($auth ?? []); // But don't worry as $auth array will have user, user/pass or pass as needed
272272
}
273273

274-
if (isset($parsedUrl['query'])) {
275-
parse_str($parsedUrl['query'], $dsnOptions);
274+
if (isset($params['query'])) {
275+
parse_str($params['query'], $dsnOptions);
276276
$option 69CE s = array_merge($options, $dsnOptions);
277277
}
278-
$parsedUrl['scheme'] = $scheme;
278+
$params['scheme'] = $scheme;
279279

280-
return $parsedUrl;
280+
return $params;
281281
}
282282

283283
private function claimOldPendingMessages(): void

0 commit comments

Comments
 (0)
0