Skip to content

Commit ea215e1

Browse files
committed
fix sending request to paths containing multiple slashes
1 parent 8a62b40 commit ea215e1

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/Symfony/Component/BrowserKit/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ protected function getAbsoluteUri($uri)
676676
}
677677

678678
// protocol relative URL
679-
if (str_starts_with($uri, '//')) {
679+
if ('' !== trim($uri, '/') && str_starts_with($uri, '//')) {
680680
return parse_url($currentUri, \PHP_URL_SCHEME).':'.$uri;
681681
}
682682

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,30 @@ public function testMultiPartRequestWithAdditionalParametersOfTheSameName()
172172
]);
173173
}
174174

175+
/**
176+
* @dataProvider forwardSlashesRequestPathProvider
177+
*/
178+
public function testMultipleForwardSlashesRequestPath(string $requestPath)
179+
{
180+
$client = $this->createMock(HttpClientInterface::class);
181+
$client
182+
->expects($this->once())
183+
->method('request')
184+
->with('GET', 'http://localhost'.$requestPath)
185+
->willReturn($this->createMock(ResponseInterface::class));
186+
$browser = new HttpBrowser($client);
187+
$browser->request('GET', $requestPath);
188+
}
189+
190+
public function forwardSlashesRequestPathProvider()
191+
{
192+
return [
193+
'one slash' => ['/'],
194+
'two slashes' => ['//'],
195+
'multiple slashes' => ['////'],
196+
];
197+
}
198+
175199
private function uploadFile(string $data): string
176200
{
177201
$path = tempnam(sys_get_temp_dir(), 'http');

0 commit comments

Comments
 (0)