Skip to content

Commit ca6d686

Browse files
Merge branch '6.4' into 7.1
* 6.4: [HttpFoundation] Fix test [HttpFoundation] Revert risk change [Notifier] Fix GoIpTransport [HttpClient] Fix catching some invalid Location headers
2 parents 691b2e1 + dc05831 commit ca6d686

File tree

8 files changed

+19
-25
lines changed

8 files changed

+19
-25
lines changed

src/Symfony/Component/HttpClient/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);

src/Symfony/Component/HttpClient/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) {

src/Symfony/Component/HttpClient/Tests/HttpClientTestCase.php

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

497-
$response = $client->request('GET', 'http://localhost:8057/302-no-scheme');
497+
$response = $client->request('GET', 'http://localhost:8057/302?location=localhost:8067');
498+
499+
$this->assertSame(302, $response->getStatusCode());
500+
501+
$response = $client->request('GET', 'http://localhost:8057/302?location=http:localhost');
498502

499503
$this->assertSame(302, $response->getStatusCode());
500504
}

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,9 @@ public static function create(string $uri, string $method = 'GET', array $parame
324324
if ('https' === $components['scheme']) {
325325
$server['HTTPS'] = 'on';
326326
$server['SERVER_PORT'] = 443;
327-
} elseif ('http' === $components['scheme']) {
327+
} else {
328328
unset($server['HTTPS']);
329329
$server['SERVER_PORT'] = 80;
330-
} else {
331-
throw new BadRequestException('Invalid URI: http(s) scheme expected.');
332330
}
333331
}
334332

src/Symfony/Component/HttpFoundation/Tests/RequestTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,6 @@ public function testCreateWithRequestUri()
311311
* [" foo"]
312312
* ["foo "]
313313
* ["//"]
314-
* ["foo:bar"]
315314
*/
316315
public function testCreateWithBadRequestUri(string $uri)
317316
{

src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/ConnectionTest.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function testFromDsnWithMixDsnQueryOptions()
106106

107107
$this->assertEquals(
108108
Connection::fromDsn('redis://localhost/queue/group1/consumer1', ['consumer' => 'specific-consumer'], $this->createRedisMock()),
109-
Connection::fromDsn('redis://localhost/queue/group1/consumer1', [], $this->createRedisMock()))
109+
Connection::fromDsn('redis://localhost/queue/group1/consumer1', [], $this->createRedisMock())
110110
);
111111
}
112112

@@ -439,8 +439,7 @@ public function testFromDsnOnUnixSocketWithUserAndPassword()
439439
'delete_after_ack' => true,
440440
'host' => '/var/run/redis/redis.sock',
441441
'port' => 0,
442-
'user' => 'user',
443-
'pass' => 'password',
442+
'auth' => ['user', 'password'],
444443
], $redis),
445444
Connection::fromDsn('redis://user:password@/var/run/redis/redis.sock', ['stream' => 'queue', 'delete_after_ack' => true], $redis)
446445
);
@@ -460,7 +459,7 @@ public function testFromDsnOnUnixSocketWithPassword()
460459
'delete_after_ack' => true,
461460
'host' => '/var/run/redis/redis.sock',
462461
'port' => 0,
463-
'pass' => 'password',
462+
'auth' => 'password',
464463
], $redis),
465464
Connection::fromDsn('redis://password@/var/run/redis/redis.sock', ['stream' => 'queue', 'delete_after_ack' => true], $redis)
466465
);
@@ -480,7 +479,7 @@ public function testFromDsnOnUnixSocketWithUser()
480479
'delete_after_ack' => true,
481480
'host' => '/var/run/redis/redis.sock',
482481
'port' => 0,
483-
'user' => 'user',
482+
'auth' => 'user',
484483
], $redis),
485484
Connection::fromDsn('redis://user:@/var/run/redis/redis.sock', ['stream' => 'queue', 'delete_after_ack' => true], $redis)
486485
);
@@ -494,7 +493,7 @@ private function createRedisMock(): \Redis
494493
->willReturn(true);
495494
$redis->expects($this->any())
496495
->method('isConnected')
497-
->willReturnOnConsecutiveCalls(false, true);
496+
->willReturnOnConsecutiveCalls(false, true, true);
498497

499498
return $redis;
500499
}

src/Symfony/Component/Notifier/Bridge/GoIp/GoIpTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected function doSend(MessageInterface $message): SentMessage
7070
throw new LogicException(sprintf('The "%s" transport does not support the "From" option.', __CLASS__));
7171
}
7272

73-
$response = $this->client->request('GET', $this->getEndpoint(), [
73+
$response = $this->client->request('GET', 'https://'.$this->getEndpoint(), [
7474
'query' => [
7575
'u' => $this->username,
7676
'p' => $this->password,

src/Symfony/Contracts/HttpClient/Test/Fixtures/web/index.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
$json = json_encode($vars, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE);
3333

34-
switch ($vars['REQUEST_URI']) {
34+
switch (parse_url($vars['REQUEST_URI'], \PHP_URL_PATH)) {
3535
default:
3636
exit;
3737

@@ -94,13 +94,8 @@
9494

9595
case '/302':
9696
if (!isset($vars['HTTP_AUTHORIZATION'])) {
97-
header('Location: http://localhost:8057/', true, 302);
98-
}
99-
break;
100-
101-
case '/302-no-scheme':
102-
if (!isset($vars['HTTP_AUTHORIZATION'])) {
103-
header('Location: localhost:8067', true, 302);
97+
$location = $_GET['location'] ?? 'http://localhost:8057/';
98+
header('Location: '.$location, true, 302);
10499
}
105100
break;
106101

0 commit comments

Comments
 (0)