Skip to content

Commit 29498a9

Browse files
Merge branch '5.4' into 6.4
* 5.4: [HttpFoundation] Revert risk change [HttpClient] Fix catching some invalid Location headers
2 parents 3208197 + 3152617 commit 29498a9

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

CurlHttpClient.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,8 @@ private static function createRedirectResolver(array $options, string $host, int
421421
try {
422422
$locationHasHost = false;
423423
$location = self::parseUrl($location);
424+
$url = self::parseUrl(curl_getinfo($ch, \CURLINFO_EFFECTIVE_URL));
425+
$url = self::resolveUrl($location, $url);
424426
} catch (InvalidArgumentException) {
425427
return null;
426428
}
@@ -441,9 +443,6 @@ private static function createRedirectResolver(array $options, string $host, int
441443
curl_setopt($ch, \CURLOPT_HTTPHEADER, $redirectHeaders['with_auth']);
442444
}
443445

444-
$url = self::parseUrl(curl_getinfo($ch, \CURLINFO_EFFECTIVE_URL));
445-
$url = self::resolveUrl($location, $url);
446-
447446
curl_setopt($ch, \CURLOPT_PROXY, self::getProxyUrl($options['proxy'], $url));
448447

449448
return implode('', $url);

NativeHttpClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,14 +383,14 @@ private static function createRedirectResolver(array $options, string $host, str
383383

384384
try {
385385
$url = self::parseUrl($location);
386+
$locationHasHost = isset($url['authority']);
387+
$url = self::resolveUrl($url, $info['url']);
386388
} catch (InvalidArgumentException) {
387389
$info['redirect_url'] = null;
388390

389391
return null;
390392
}
391393

392-
$locationHasHost = isset($url['authority']);
393-
$url = self::resolveUrl($url, $info['url']);
394394
$info['redirect_url'] = implode('', $url);
395395

396396
if ($info['redirect_count'] >= $maxRedirects) {

Tests/HttpClientTestCase.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,11 @@ public function testNoRedirectWithInvalidLocation()
489489
{
490490
$client = $this->getHttpClient(__FUNCTION__);
491491

492-
$response = $client->request('GET', 'http://localhost:8057/302-no-scheme');
492+
$response = $client->request('GET', 'http://localhost:8057/302?location=localhost:8067');
493+
494+
$this->assertSame(302, $response->getStatusCode());
495+
496+
$response = $client->request('GET', 'http://localhost:8057/302?location=http:localhost');
493497

494498
$this->assertSame(302, $response->getStatusCode());
495499
}

0 commit comments

Comments
 (0)