From 9aa64ef56467ea1660b09654b49be426dcd55ec1 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 1 Jun 2009 00:01:58 +0000 Subject: [PATCH] Ensuring that 'ext' param added by RequestHandler does not end up as a queryString parameter in Auth.redirect. Adding test case. Fixes #6211 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8182 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/controller/components/auth.php | 2 +- .../libs/controller/components/auth.test.php | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index a8744ce25..a638fd567 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -339,7 +339,7 @@ class AuthComponent extends Object { $this->Session->setFlash($this->authError, 'default', array(), 'auth'); if (!empty($controller->params['url']) && count($controller->params['url']) >= 2) { $query = $controller->params['url']; - unset($query['url']); + unset($query['url'], $query['ext']); $url .= Router::queryString($query, array()); } $this->Session->write('Auth.redirect', $url); diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 3cdb25bb7..00bf8a9c6 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -728,6 +728,7 @@ class AuthTest extends CakeTestCase { $this->Controller->params['action'] = 'Add'; $this->assertFalse($this->Controller->Auth->startup($this->Controller)); } + /** * testLoginRedirect method * @@ -854,6 +855,22 @@ class AuthTest extends CakeTestCase { $this->Controller->Auth->startup($this->Controller); $expected = Router::normalize('posts/index/29?print=true&refer=menu'); $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); + + $_GET = array( + 'url' => '/posts/index/29', + 'print' => 'true', + 'refer' => 'menu', + 'ext' => 'html' + ); + $this->Controller->Session->del('Auth'); + $url = '/posts/index/29?print=true&refer=menu'; + $this->Controller->params = Dispatcher::parseParams($url); + $this->Controller->Auth->initialize($this->Controller); + $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); + $this->Controller->Auth->userModel = 'AuthUser'; + $this->Controller->Auth->startup($this->Controller); + $expected = Router::normalize('posts/index/29?print=true&refer=menu'); + $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); $_GET = $_back; //external authed action