diff options
author | Fabien Potencier <fabien.potencier@gmail.com> | 2013-03-20 15:03:03 +0100 |
---|---|---|
committer | Fabien Potencier <fabien.potencier@gmail.com> | 2013-03-20 15:03:03 +0100 |
commit | ab9e18a00d9da04e7ff5f204ed88bc8307e2bec9 (patch) | |
tree | 1368c15cc2c6da707bf19df3adcdc143fb3d8299 | |
parent | 47037a7958cd3968161fc08710bc30cad1eba115 (diff) | |
parent | d6e78258d9049f137549718524585e8822b06d95 (diff) | |
download | symfony-security-ab9e18a00d9da04e7ff5f204ed88bc8307e2bec9.zip symfony-security-ab9e18a00d9da04e7ff5f204ed88bc8307e2bec9.tar.gz symfony-security-ab9e18a00d9da04e7ff5f204ed88bc8307e2bec9.tar.bz2 |
Merge branch '2.2'
* 2.2: (70 commits)
change wrapped exception message to be more usefull
updated VERSION for 2.0.23
update CONTRIBUTORS for 2.0.23
updated CHANGELOG for 2.0.23
[Form] fixed failing test
[DomCrawler] added support for query string with slash
Fixed invalid file path for hiddeninput.exe on Windows.
fix xsd definition for strict-requirements
[WebProfilerBundle] Fixed the toolbar styles to apply them in IE8
[ClassLoader] fixed heredocs handling
fixed handling of heredocs
Add a public modifier to an interface method
removing xdebug extension
[HttpRequest] fixes Request::getLanguages() bug
[HttpCache] added a test (cached content should be kept after purging)
[DoctrineBridge] Fixed non-utf-8 recognition
[Security] fixed HttpUtils class tests
replaced new occurences of 'Request::create()' with '::create()'
changed sub-requests creation to '::create()'
fixed merge issue
...
Conflicts:
src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php
src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.html.twig
src/Symfony/Component/DomCrawler/Link.php
src/Symfony/Component/Translation/Translator.php
-rw-r--r-- | Core/Authentication/Provider/AuthenticationProviderInterface.php | 2 | ||||
-rw-r--r-- | Http/HttpUtils.php | 14 | ||||
-rw-r--r-- | Tests/Http/HttpUtilsTest.php | 16 |
3 files changed, 27 insertions, 5 deletions
diff --git a/Core/Authentication/Provider/AuthenticationProviderInterface.php b/Core/Authentication/Provider/AuthenticationProviderInterface.php index 956adf1..f63a924 100644 --- a/Core/Authentication/Provider/AuthenticationProviderInterface.php +++ b/Core/Authentication/Provider/AuthenticationProviderInterface.php @@ -31,5 +31,5 @@ interface AuthenticationProviderInterface extends AuthenticationManagerInterface * * @return Boolean true if the implementation supports the Token, false otherwise */ - function supports(TokenInterface $token); + public function supports(TokenInterface $token); } diff --git a/Http/HttpUtils.php b/Http/HttpUtils.php index eb7894c..0453520 100644 --- a/Http/HttpUtils.php +++ b/Http/HttpUtils.php @@ -70,7 +70,7 @@ class HttpUtils */ public function createRequest(Request $request, $path) { - $newRequest = Request::create($this->generateUri($request, $path), 'get', array(), $request->cookies->all(), array(), $request->server->all()); + $newRequest = $request::create($this->generateUri($request, $path), 'get', array(), $request->cookies->all(), array(), $request->server->all()); if ($request->hasSession()) { $newRequest->setSession($request->getSession()); } @@ -140,6 +140,16 @@ class HttpUtils throw new \LogicException('You must provide a UrlGeneratorInterface instance to be able to use routes.'); } - return $this->urlGenerator->generate($path, array(), UrlGeneratorInterface::ABSOLUTE_URL); + $url = $this->urlGenerator->generate($path, $request->attributes->all(), UrlGeneratorInterface::ABSOLUTE_URL); + + // unnecessary query string parameters must be removed from url + // (ie. query parameters that are presents in $attributes) + // fortunately, they all are, so we have to remove entire query string + $position = strpos($url, '?'); + if (false !== $position) { + $url = substr($url, 0, $position); + } + + return $url; } } diff --git a/Tests/Http/HttpUtilsTest.php b/Tests/Http/HttpUtilsTest.php index fc1b754..bf078da 100644 --- a/Tests/Http/HttpUtilsTest.php +++ b/Tests/Http/HttpUtilsTest.php @@ -137,13 +137,25 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase $utils->checkRequestPath($this->getRequest(), 'foobar'); } - private function getUrlGenerator() + public function testGenerateUriRemovesQueryString() + { + $method = new \ReflectionMethod('Symfony\Component\Security\Http\HttpUtils', 'generateUri'); + $method->setAccessible(true); + + $utils = new HttpUtils($this->getUrlGenerator()); + $this->assertEquals('/foo/bar', $method->invoke($utils, new Request(), 'route_name')); + + $utils = new HttpUtils($this->getUrlGenerator('/foo/bar?param=value')); + $this->assertEquals('/foo/bar', $method->invoke($utils, new Request(), 'route_name')); + } + + private function getUrlGenerator($generatedUrl = '/foo/bar') { $urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface'); $urlGenerator ->expects($this->any()) ->method('generate') - ->will($this->returnValue('/foo/bar')) + ->will($this->returnValue($generatedUrl)) ; return $urlGenerator; |