From 86701b8cd0cd5f8de813a7c9347e7c8055d878f4 Mon Sep 17 00:00:00 2001 From: Loz Calver Date: Thu, 15 Nov 2018 11:15:31 +0000 Subject: [PATCH] FIX: Redirect loop with multiple URL tokens (fixes #8607) --- core/startup/ConfirmationTokenChain.php | 5 +++-- tests/core/startup/ConfirmationTokenChainTest.php | 12 +++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/core/startup/ConfirmationTokenChain.php b/core/startup/ConfirmationTokenChain.php index 9938285c0..660b64c46 100644 --- a/core/startup/ConfirmationTokenChain.php +++ b/core/startup/ConfirmationTokenChain.php @@ -123,9 +123,10 @@ class ConfirmationTokenChain * @return array */ public function getRedirectUrlParams() { - $params = array(); + $params = $_GET; + unset($params['url']); foreach ($this->filteredTokens() as $token) { - $params = array_merge($params, $token->getRedirectUrlParams()); + $params = array_merge($params, $token->params()); } return $params; diff --git a/tests/core/startup/ConfirmationTokenChainTest.php b/tests/core/startup/ConfirmationTokenChainTest.php index fad9ea2c4..d6a2fa2bc 100644 --- a/tests/core/startup/ConfirmationTokenChainTest.php +++ b/tests/core/startup/ConfirmationTokenChainTest.php @@ -123,19 +123,21 @@ class ConfirmationTokenChainTest extends SapphireTest { } public function testGetRedirectUrlParams() { - $mockToken = $this->getTokenRequiringReload(true, array('getRedirectUrlParams')); + $mockToken = $this->getTokenRequiringReload(true, array('params')); $mockToken->expects($this->once()) - ->method('getRedirectUrlParams') + ->method('params') ->will($this->returnValue(array('mockTokenParam' => '1'))); - $secondMockToken = $this->getTokenRequiringReload(true, array('getRedirectUrlParams')); + $secondMockToken = $this->getTokenRequiringReload(true, array('params')); $secondMockToken->expects($this->once()) - ->method('getRedirectUrlParams') + ->method('params') ->will($this->returnValue(array('secondMockTokenParam' => '2'))); $chain = new ConfirmationTokenChain(); $chain->pushToken($mockToken); $chain->pushToken($secondMockToken); - $this->assertEquals(array('mockTokenParam' => '1', 'secondMockTokenParam' => '2'), $chain->getRedirectUrlParams()); + $params = $chain->getRedirectUrlParams(); + $this->assertEquals('1', $params['mockTokenParam']); + $this->assertEquals('2', $params['secondMockTokenParam']); } }