From 65b98102d16d99db96bf509b270b2a304f38adbb Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 27 Mar 2014 10:08:38 +0100 Subject: [PATCH] fixed too greedy replacements --- src/Symfony/Component/BrowserKit/Client.php | 4 ++-- src/Symfony/Component/BrowserKit/Tests/ClientTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/BrowserKit/Client.php b/src/Symfony/Component/BrowserKit/Client.php index 2e5aedc529..ecabc680e2 100644 --- a/src/Symfony/Component/BrowserKit/Client.php +++ b/src/Symfony/Component/BrowserKit/Client.php @@ -304,11 +304,11 @@ abstract class Client $uri = $this->getAbsoluteUri($uri); if (isset($server['HTTP_HOST'])) { - $uri = str_replace(parse_url($uri, PHP_URL_HOST), $server['HTTP_HOST'], $uri); + $uri = preg_replace('{^(https?\://)'.parse_url($uri, PHP_URL_HOST).'}', '\\1'.$server['HTTP_HOST'], $uri); } if (isset($server['HTTPS'])) { - $uri = str_replace(parse_url($uri, PHP_URL_SCHEME), $server['HTTPS'] ? 'https' : 'http', $uri); + $uri = preg_replace('{^'.parse_url($uri, PHP_URL_SCHEME).'}', $server['HTTPS'] ? 'https' : 'http', $uri); } $server = array_merge($this->server, $server); diff --git a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php index 4ebe96e7e9..f8c128f138 100644 --- a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php @@ -593,7 +593,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase $this->assertEquals('localhost', $client->getServerParameter('HTTP_HOST')); $this->assertEquals('Symfony2 BrowserKit', $client->getServerParameter('HTTP_USER_AGENT')); - $client->request('GET', 'https://www.example.com/foo', array(), array(), array( + $client->request('GET', 'https://www.example.com/https/www.example.com', array(), array(), array( 'HTTP_HOST' => 'testhost', 'HTTP_USER_AGENT' => 'testua', 'HTTPS' => false, @@ -603,7 +603,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase $this->assertEquals('localhost', $client->getServerParameter('HTTP_HOST')); $this->assertEquals('Symfony2 BrowserKit', $client->getServerParameter('HTTP_USER_AGENT')); - $this->assertEquals('http://testhost/foo', $client->getRequest()->getUri()); + $this->assertEquals('http://testhost/https/www.example.com', $client->getRequest()->getUri()); $server = $client->getRequest()->getServer();