mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX: Redirect loop with multiple URL tokens (fixes #8607)
This commit is contained in:
parent
598edd9134
commit
86701b8cd0
@ -123,9 +123,10 @@ class ConfirmationTokenChain
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getRedirectUrlParams() {
|
public function getRedirectUrlParams() {
|
||||||
$params = array();
|
$params = $_GET;
|
||||||
|
unset($params['url']);
|
||||||
foreach ($this->filteredTokens() as $token) {
|
foreach ($this->filteredTokens() as $token) {
|
||||||
$params = array_merge($params, $token->getRedirectUrlParams());
|
$params = array_merge($params, $token->params());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $params;
|
return $params;
|
||||||
|
@ -123,19 +123,21 @@ class ConfirmationTokenChainTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testGetRedirectUrlParams() {
|
public function testGetRedirectUrlParams() {
|
||||||
$mockToken = $this->getTokenRequiringReload(true, array('getRedirectUrlParams'));
|
$mockToken = $this->getTokenRequiringReload(true, array('params'));
|
||||||
$mockToken->expects($this->once())
|
$mockToken->expects($this->once())
|
||||||
->method('getRedirectUrlParams')
|
->method('params')
|
||||||
->will($this->returnValue(array('mockTokenParam' => '1')));
|
->will($this->returnValue(array('mockTokenParam' => '1')));
|
||||||
|
|
||||||
$secondMockToken = $this->getTokenRequiringReload(true, array('getRedirectUrlParams'));
|
$secondMockToken = $this->getTokenRequiringReload(true, array('params'));
|
||||||
$secondMockToken->expects($this->once())
|
$secondMockToken->expects($this->once())
|
||||||
->method('getRedirectUrlParams')
|
->method('params')
|
||||||
->will($this->returnValue(array('secondMockTokenParam' => '2')));
|
->will($this->returnValue(array('secondMockTokenParam' => '2')));
|
||||||
|
|
||||||
$chain = new ConfirmationTokenChain();
|
$chain = new ConfirmationTokenChain();
|
||||||
$chain->pushToken($mockToken);
|
$chain->pushToken($mockToken);
|
||||||
$chain->pushToken($secondMockToken);
|
$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']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user