Skip to content

Commit 3c38f89

Browse files
Merge branch '6.2' into 6.3
* 6.2: [HttpClient] fix proxied redirects in curl client Fix serializer normalize attribute context Bump Symfony version to 6.2.10 Update VERSION for 6.2.9 Update CHANGELOG for 6.2.9 [Intl] Update the ICU data to 73.1 [Console] Restoring the ability to output unicode text to the Win10 console [Mailer] Add brifge documentation
2 parents 95cf988 + 7a3fda8 commit 3c38f89

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

CurlHttpClient.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,7 @@ public function request(string $method, string $url, array $options = []): Respo
8989
$authority = $url['authority'];
9090
$host = parse_url($authority, \PHP_URL_HOST);
9191
$port = parse_url($authority, \PHP_URL_PORT) ?: ('http:' === $scheme ? 80 : 443);
92-
$proxy = $options['proxy']
93-
?? ('https:' === $url['scheme'] ? $_SERVER['https_proxy'] ?? $_SERVER['HTTPS_PROXY'] ?? null : null)
94-
// Ignore HTTP_PROXY except on the CLI to work around httpoxy set of vulnerabilities
95-
?? $_SERVER['http_proxy'] ?? (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) ? $_SERVER['HTTP_PROXY'] ?? null : null) ?? $_SERVER['all_proxy'] ?? $_SERVER['ALL_PROXY'] ?? null;
92+
$proxy = self::getProxyUrl($options['proxy'], $url);
9693
$url = implode('', $url);
9794

9895
if (!isset($options['normalized_headers']['user-agent'])) {
@@ -397,7 +394,7 @@ private static function createRedirectResolver(array $options, string $host, int
397394
}
398395
}
399396

400-
return static function ($ch, string $location, bool $noContent) use (&$redirectHeaders) {
397+
return static function ($ch, string $location, bool $noContent) use (&$redirectHeaders, $options) {
401398
try {
402399
$location = self::parseUrl($location);
403400
} catch (InvalidArgumentException) {
@@ -421,11 +418,7 @@ private static function createRedirectResolver(array $options, string $host, int
421418
$url = self::parseUrl(curl_getinfo($ch, \CURLINFO_EFFECTIVE_URL));
422419
$url = self::resolveUrl($location, $url);
423420

424-
curl_setopt($ch, \CURLOPT_PROXY, $options['proxy']
425-
?? ('https:' === $url['scheme'] ? $_SERVER['https_proxy'] ?? $_SERVER['HTTPS_PROXY'] ?? null : null)
426-
// Ignore HTTP_PROXY except on the CLI to work around httpoxy set of vulnerabilities
427-
?? $_SERVER['http_proxy'] ?? (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) ? $_SERVER['HTTP_PROXY'] ?? null : null) ?? $_SERVER['all_proxy'] ?? $_SERVER['ALL_PROXY'] ?? null
428-
);
421+
curl_setopt($ch, \CURLOPT_PROXY, self::getProxyUrl($options['proxy'], $url));
429422

430423
return implode('', $url);
431424
};

HttpClientTrait.php

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -652,16 +652,7 @@ private static function mergeQueryString(?string $queryString, array $queryArray
652652
*/
653653
private static function getProxy(?string $proxy, array $url, ?string $noProxy): ?array
654654
{
655-
if (null === $proxy) {
656-
// Ignore HTTP_PROXY except on the CLI to work around httpoxy set of vulnerabilities
657-
$proxy = $_SERVER['http_proxy'] ?? (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) ? $_SERVER['HTTP_PROXY'] ?? null : null) ?? $_SERVER['all_proxy'] ?? $_SERVER['ALL_PROXY'] ?? null;
658-
659-
if ('https:' === $url['scheme']) {
660-
$proxy = $_SERVER['https_proxy'] ?? $_SERVER['HTTPS_PROXY'] ?? $proxy;
661-
}
662-
}
663-
664-
if (null === $proxy) {
655+
if (null === $proxy = self::getProxyUrl($proxy, $url)) {
665656
return null;
666657
}
667658

@@ -689,6 +680,22 @@ private static function getProxy(?string $proxy, array $url, ?string $noProxy):
689680
];
690681
}
691682

683+
private static function getProxyUrl(?string $proxy, array $url): ?string
684+
{
685+
if (null !== $proxy) {
686+
return $proxy;
687+
}
688+
689+
// Ignore HTTP_PROXY except on the CLI to work around httpoxy set of vulnerabilities
690+
$proxy = $_SERVER['http_proxy'] ?? (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) ? $_SERVER['HTTP_PROXY'] ?? null : null) ?? $_SERVER['all_proxy'] ?? $_SERVER['ALL_PROXY'] ?? null;
691+
692+
if ('https:' === $url['scheme']) {
693+
$proxy = $_SERVER['https_proxy'] ?? $_SERVER['HTTPS_PROXY'] ?? $proxy;
694+
}
695+
696+
return $proxy;
697+
}
698+
692699
private static function shouldBuffer(array $headers): bool
693700
{
694701
if (null === $contentType = $headers['content-type'][0] ?? null) {

0 commit comments

Comments
 (0)