Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e5fe662

Browse filesBrowse files
Merge branch '7.2' into 7.3
* 7.2: [HttpClient] More consistency cleanups [HttpClient] Remove unrelevant test [DependencyInjection] Fix PhpDoc type CS: apply minor indentation fixes
2 parents 4786a74 + 1156804 commit e5fe662
Copy full SHA for e5fe662

File tree

Expand file treeCollapse file tree

8 files changed

+32
-43
lines changed
Filter options
Expand file treeCollapse file tree

8 files changed

+32
-43
lines changed

‎src/Symfony/Bridge/Twig/EventListener/TemplateAttributeListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/EventListener/TemplateAttributeListener.php
+10-10Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,16 @@ public function onKernelView(ViewEvent $event): void
5555
}
5656

5757
$event->setResponse($attribute->stream
58-
? new StreamedResponse(
59-
null !== $attribute->block
60-
? fn () => $this->twig->load($attribute->template)->displayBlock($attribute->block, $parameters)
61-
: fn () => $this->twig->display($attribute->template, $parameters),
62-
$status)
63-
: new Response(
64-
null !== $attribute->block
65-
? $this->twig->load($attribute->template)->renderBlock($attribute->block, $parameters)
66-
: $this->twig->render($attribute->template, $parameters),
67-
$status)
58+
? new StreamedResponse(
59+
null !== $attribute->block
60+
? fn () => $this->twig->load($attribute->template)->displayBlock($attribute->block, $parameters)
61+
: fn () => $this->twig->display($attribute->template, $parameters),
62+
$status)
63+
: new Response(
64+
null !== $attribute->block
65+
? $this->twig->load($attribute->template)->renderBlock($attribute->block, $parameters)
66+
: $this->twig->render($attribute->template, $parameters),
67+
$status)
6868
);
6969
}
7070

‎src/Symfony/Component/DependencyInjection/Attribute/AutowireLocator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Attribute/AutowireLocator.php
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ class AutowireLocator extends Autowire
2828
/**
2929
* @see ServiceSubscriberInterface::getSubscribedServices()
3030
*
31-
* @param string|array<string|SubscribedService> $services A tag name or an explicit list of service ids
32-
* @param string|null $indexAttribute The name of the attribute that defines the key referencing each service in the locator
33-
* @param string|null $defaultIndexMethod The static method that should be called to get each service's key when their tag doesn't define the previous attribute
34-
* @param string|null $defaultPriorityMethod The static method that should be called to get each service's priority when their tag doesn't define the "priority" attribute
35-
* @param string|array $exclude A service id or a list of service ids to exclude
36-
* @param bool $excludeSelf Whether to automatically exclude the referencing service from the locator
31+
* @param string|array<string|Autowire|SubscribedService> $services A tag name or an explicit list of service ids
32+
* @param string|null $indexAttribute The name of the attribute that defines the key referencing each service in the locator
33+
* @param string|null $defaultIndexMethod The static method that should be called to get each service's key when their tag doesn't define the previous attribute
34+
* @param string|null $defaultPriorityMethod The static method that should be called to get each service's priority when their tag doesn't define the "priority" attribute
35+
* @param string|array $exclude A service id or a list of service ids to exclude
36+
* @param bool $excludeSelf Whether to automatically exclude the referencing service from the locator
3737
*/
3838
public function __construct(
3939
string|array $services,

‎src/Symfony/Component/HttpClient/CurlHttpClient.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/CurlHttpClient.php
+4-6Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ public function request(string $method, string $url, array $options = []): Respo
323323
}
324324
}
325325

326-
return $pushedResponse ?? new CurlResponse($multi, $ch, $options, $this->logger, $method, self::createRedirectResolver($options, $host, $port), CurlClientState::$curlVersion['version_number'], $url);
326+
return $pushedResponse ?? new CurlResponse($multi, $ch, $options, $this->logger, $method, self::createRedirectResolver($options, $authority), CurlClientState::$curlVersion['version_number'], $url);
327327
}
328328

329329
public function stream(ResponseInterface|iterable $responses, ?float $timeout = null): ResponseStreamInterface
@@ -404,12 +404,11 @@ private static function readRequestBody(int $length, \Closure $body, string &$bu
404404
*
405405
* Work around CVE-2018-1000007: Authorization and Cookie headers should not follow redirects - fixed in Curl 7.64
406406
*/
407-
private static function createRedirectResolver(array $options, string $host, int $port): \Closure
407+
private static function createRedirectResolver(array $options, string $authority): \Closure
408408
{
409409
$redirectHeaders = [];
410410
if (0 < $options['max_redirects']) {
411-
$redirectHeaders['host'] = $host;
412-
$redirectHeaders['port'] = $port;
411+
$redirectHeaders['authority'] = $authority;
413412
$redirectHeaders['with_auth'] = $redirectHeaders['no_auth'] = array_filter($options['headers'], static fn ($h) => 0 !== stripos($h, 'Host:'));
414413

415414
if (isset($options['normalized_headers']['authorization'][0]) || isset($options['normalized_headers']['cookie'][0])) {
@@ -433,8 +432,7 @@ private static function createRedirectResolver(array $options, string $host, int
433432
}
434433

435434
if ($redirectHeaders && isset($location['authority'])) {
436-
$port = parse_url($location['authority'], \PHP_URL_PORT) ?: ('http:' === $location['scheme'] ? 80 : 443);
437-
$requestHeaders = parse_url($location['authority'], \PHP_URL_HOST) === $redirectHeaders['host'] && $redirectHeaders['port'] === $port ? $redirectHeaders['with_auth'] : $redirectHeaders['no_auth'];
435+
$requestHeaders = $location['authority'] === $redirectHeaders['authority'] ? $redirectHeaders['with_auth'] : $redirectHeaders['no_auth'];
438436
curl_setopt($ch, \CURLOPT_HTTPHEADER, $requestHeaders);
439437
} elseif ($noContent && $redirectHeaders) {
440438
curl_setopt($ch, \CURLOPT_HTTPHEADER, $redirectHeaders['with_auth']);

‎src/Symfony/Component/HttpClient/NativeHttpClient.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/NativeHttpClient.php
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ public function request(string $method, string $url, array $options = []): Respo
262262
$context = stream_context_create($context, ['notification' => $notification]);
263263

264264
$resolver = static function ($multi) use ($context, $options, $url, &$info, $onProgress) {
265+
$authority = $url['authority'];
265266
[$host, $port] = self::parseHostPort($url, $info);
266267

267268
if (!isset($options['normalized_headers']['host'])) {
@@ -275,7 +276,7 @@ public function request(string $method, string $url, array $options = []): Respo
275276
$url['authority'] = substr_replace($url['authority'], $ip, -\strlen($host) - \strlen($port), \strlen($host));
276277
}
277278

278-
return [self::createRedirectResolver($options, $host, $port, $proxy, $info, $onProgress), implode('', $url)];
279+
return [self::createRedirectResolver($options, $authority, $proxy, $info, $onProgress), implode('', $url)];
279280
};
280281

281282
return new NativeResponse($this->multi, $context, implode('', $url), $options, $info, $resolver, $onProgress, $this->logger);
@@ -373,11 +374,11 @@ private static function dnsResolve(string $host, NativeClientState $multi, array
373374
/**
374375
* Handles redirects - the native logic is too buggy to be used.
375376
*/
376-
private static function createRedirectResolver(array $options, string $host, string $port, ?array $proxy, array &$info, ?\Closure $onProgress): \Closure
377+
private static function createRedirectResolver(array $options, string $authority, ?array $proxy, array &$info, ?\Closure $onProgress): \Closure
377378
{
378379
$redirectHeaders = [];
379380
if (0 < $maxRedirects = $options['max_redirects']) {
380-
$redirectHeaders = ['host' => $host, 'port' => $port];
381+
$redirectHeaders = ['authority' => $authority];
381382
$redirectHeaders['with_auth'] = $redirectHeaders['no_auth'] = array_filter($options['headers'], static fn ($h) => 0 !== stripos($h, 'Host:'));
382383

383384
if (isset($options['normalized_headers']['authorization']) || isset($options['normalized_headers']['cookie'])) {
@@ -435,8 +436,8 @@ private static function createRedirectResolver(array $options, string $host, str
435436
[$host, $port] = self::parseHostPort($url, $info);
436437

437438
if ($locationHasHost) {
438-
// Authorization and Cookie headers MUST NOT follow except for the initial host name
439-
$requestHeaders = $redirectHeaders['host'] === $host && $redirectHeaders['port'] === $port ? $redirectHeaders['with_auth'] : $redirectHeaders['no_auth'];
439+
// Authorization and Cookie headers MUST NOT follow except for the initial authority name
440+
$requestHeaders = $redirectHeaders['authority'] === $url['authority'] ? $redirectHeaders['with_auth'] : $redirectHeaders['no_auth'];
440441
$requestHeaders[] = 'Host: '.$host.$port;
441442
$dnsResolve = !self::configureHeadersAndProxy($context, $host, $requestHeaders, $proxy, 'https:' === $url['scheme']);
442443
} else {

‎src/Symfony/Component/HttpClient/Response/AmpResponseV4.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/Response/AmpResponseV4.php
+4-6Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,16 +341,14 @@ private static function followRedirects(Request $originRequest, AmpClientStateV4
341341
$request->setTlsHandshakeTimeout($originRequest->getTlsHandshakeTimeout());
342342
$request->setTransferTimeout($originRequest->getTransferTimeout());
343343

344-
if (\in_array($status, [301, 302, 303], true)) {
344+
if (303 === $status || \in_array($status, [301, 302], true) && 'POST' === $response->getRequest()->getMethod()) {
345+
// Do like curl and browsers: turn POST to GET on 301, 302 and 303
345346
$originRequest->removeHeader('transfer-encoding');
346347
$originRequest->removeHeader('content-length');
347348
$originRequest->removeHeader('content-type');
348349

349-
// Do like curl and browsers: turn POST to GET on 301, 302 and 303
350-
if ('POST' === $response->getRequest()->getMethod() || 303 === $status) {
351-
$info['http_method'] = 'HEAD' === $response->getRequest()->getMethod() ? 'HEAD' : 'GET';
352-
$request->setMethod($info['http_method']);
353-
}
350+
$info['http_method'] = 'HEAD' === $response->getRequest()->getMethod() ? 'HEAD' : 'GET';
351+
$request->setMethod($info['http_method']);
354352
} else {
355353
$request->setBody(AmpBodyV4::rewind($response->getRequest()->getBody()));
356354
}

‎src/Symfony/Component/HttpClient/Tests/NoPrivateNetworkHttpClientTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/Tests/NoPrivateNetworkHttpClientTest.php
-8Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,6 @@ public function testNonCallableOnProgressCallback()
142142
$client->request('GET', $url, ['on_progress' => $customCallback]);
143143
}
144144

145-
public function testConstructor()
146-
{
147-
$this->expectException(\TypeError::class);
148-
$this->expectExceptionMessage('Argument 2 passed to "Symfony\Component\HttpClient\NoPrivateNetworkHttpClient::__construct()" must be of the type array, string or null. "int" given.');
149-
150-
new NoPrivateNetworkHttpClient(new MockHttpClient(), 3);
151-
}
152-
153145
private function getMockHttpClient(string $ipAddr, string $content)
154146
{
155147
return new MockHttpClient(new MockResponse($content, ['primary_ip' => $ipAddr]));

‎src/Symfony/Component/Intl/Tests/TimezonesTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Intl/Tests/TimezonesTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ public function testGetGmtOffsetAvailability(string $timezone)
618618
try {
619619
new \DateTimeZone($timezone);
620620
} catch (\Exception $e) {
621-
$this->markTestSkipped(sprintf('The timezone "%s" is not available.', $timezone));
621+
$this->markTestSkipped(\sprintf('The timezone "%s" is not available.', $timezone));
622622
}
623623

624624
// ensure each timezone identifier has a corresponding GMT offset

‎src/Symfony/Component/Mailer/Bridge/Mailchimp/Webhook/MailchimpRequestParser.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mailer/Bridge/Mailchimp/Webhook/MailchimpRequestParser.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ protected function doParse(Request $request, #[\SensitiveParameter] string $secr
4141
{
4242
$content = $request->toArray();
4343
if (!isset($content['mandrill_events'][0]['event'])
44-
|| !isset($content['mandrill_events'][0]['msg'])
44+
|| !isset($content['mandrill_events'][0]['msg'])
4545
) {
4646
throw new RejectWebhookException(400, 'Payload malformed.');
4747
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.