8000 [BrowserKit] Fix #10641 : BrowserKit is broken when using ip as host · romainneutron/symfony@e946da3 · GitHub
[go: up one dir, main page]

Skip to content

Commit e946da3

Browse files
committed
[BrowserKit] Fix symfony#10641 : BrowserKit is broken when using ip as host
1 parent 8aa194c commit e946da3

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Symfony/Component/BrowserKit/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ public function request($method, $uri, array $parameters = array(), array $files
304304
$uri = $this->getAbsoluteUri($uri);
305305

306306
if (isset($server['HTTP_HOST'])) {
307-
$uri = preg_replace('{^(https?\://)'.parse_url($uri, PHP_URL_HOST).'}', '\\1'.$server['HTTP_HOST'], $uri);
307+
$uri = preg_replace('{^(https?\://)'.parse_url($uri, PHP_URL_HOST).'}', '${1}'.$server['HTTP_HOST'], $uri);
308308
}
309309

310310
if (isset($server['HTTPS'])) {

src/Symfony/Component/BrowserKit/Tests/ClientTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ public function testGetRequest()
103103
$this->assertEquals('http://example.com/', $client->getRequest()->getUri(), '->getCrawler() returns the Request of the last request');
104104
}
105105

106+
public function testGetRequestWithIpAsHost()
107+
{
108+
$client = new TestClient();
109+
$client->request('GET', 'https://example.com/foo', array(), array(), array('HTTP_HOST' => '127.0.0.1'));
110+
111+
$this->assertEquals('https://127.0.0.1/foo', $client->getRequest()->getUri());
112+
}
113+
106114
public function testGetResponse()
107115
{
108116
$client = new TestClient();

0 commit comments

Comments
 (0)
0