From 570e71f62abe01e89753ccd39c05819bc4b68923 Mon Sep 17 00:00:00 2001 From: nate Date: Wed, 19 Dec 2007 01:49:25 +0000 Subject: [PATCH] Adding fix for Router named arguments where arg value contains the separator key (Ticket #3752) git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6172 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/router.php | 2 +- cake/tests/cases/libs/router.test.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cake/libs/router.php b/cake/libs/router.php index 326667c65..b2b7cac9d 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -1154,7 +1154,7 @@ class Router extends Object { ); foreach ($args as $param) { if (strpos($param, $_this->__argSeparator)) { - $param = explode($_this->__argSeparator, $param); + $param = explode($_this->__argSeparator, $param, 2); $named[$param[0]] = $param[1]; } else { $pass[] = $param; diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index e2d53e5b1..fc6aec324 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -803,6 +803,12 @@ class RouterTest extends UnitTestCase { $this->assertEqual($result, $expected); } + function testNamedArgsUrlParsing() { + $result = $this->router->parse('/controller/action/param1:value1:1/param2:value2:3/param:value'); + $expected = array('pass' => array(), 'named' => array('param1' => 'value1:1', 'param2' => 'value2:3', 'param' => 'value'), 'controller' => 'controller', 'action' => 'action', 'plugin' => null); + $this->assertEqual($result, $expected); + } + function testUrlGenerationWithPrefixes() { $this->router->reload();