diff --git a/cake/libs/router.php b/cake/libs/router.php index 414bc142d..b365d2860 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -249,7 +249,7 @@ class Router extends Object { $_this =& Router::getInstance(); if (isset($options['argSeparator'])) { - $options['separator'] = $options['argSeparator']; + $_this->named['separator'] = $options['argSeparator']; unset($options['argSeparator']); } @@ -1302,9 +1302,8 @@ class Router extends Object { continue; } $param = $_this->stripEscape($param); - if ((!isset($options['named']) || !empty($options['named'])) && strpos($param, $_this->named['separator'])) { + if ((!isset($options['named']) || !empty($options['named'])) && strpos($param, $_this->named['separator']) !== false) { list($key, $val) = explode($_this->named['separator'], $param, 2); - $hasRule = isset($rules[$key]); $passIt = (!$hasRule && !$greedy) || ($hasRule && !Router::matchNamed($key, $val, $rules[$key], $context)); if ($passIt) { diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index 898831723..2b1ac17b5 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -1032,6 +1032,20 @@ class RouterTest extends UnitTestCase { $named = Router::connectNamed(false, array('default' => true)); $this->assertFalse($named['greedy']); $this->assertEqual(array_keys($named['rules']), $named['default']); + + Router::reload(); + Router::connect('/foo/*', array('controller' => 'bar', 'action' => 'fubar')); + Router::connectNamed(array(), array('argSeparator' => '=')); + $result = Router::parse('/foo/param1=value1/param2=value2'); + $expected = array('pass' => array(), 'named' => array('param1' => 'value1', 'param2' => 'value2'), 'controller' => 'bar', 'action' => 'fubar', 'plugin' => null); + $this->assertEqual($result, $expected); + + Router::reload(); + Router::connect('/controller/action/*', array('controller' => 'controller', 'action' => 'action'), array('named' => array('param1' => 'value[\d]'))); + Router::connectNamed(array(), array('greedy' => false, 'argSeparator' => '=')); + $result = Router::parse('/controller/action/param1=value1/param2=value2'); + $expected = array('pass' => array('param2=value2'), 'named' => array('param1' => 'value1'), 'controller' => 'controller', 'action' => 'action', 'plugin' => null); + $this->assertEqual($result, $expected); } /** * testNamedArgsUrlGeneration method