diff --git a/cake/libs/router.php b/cake/libs/router.php index 7703010c8..90e869a8a 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -313,7 +313,7 @@ class Router extends Object { $names[] = $r[1]; } elseif ($element == '*') { $parsed[] = '(?:/(.*))?'; - } else if ($namedParam && preg_match_all('/(?!\\\\):([^:\\\\]+)/', $element, $matches)) { + } else if ($namedParam && preg_match_all('/(?!\\\\):([a-z_0-9]+)/i', $element, $matches)) { foreach ($matches[1] as $i => $name) { $pos = strpos($element, ':'.$name); $before = substr($element, 0, $pos); diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index b2f54c18e..a2c4d69c7 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -89,11 +89,13 @@ class RouterTest extends UnitTestCase { $this->assertEqual($this->router->routes[0][2], array('id')); $this->assertEqual($this->router->routes[0][1], '#^/posts(?:/foo([^\/]+))?[\/]*$#'); - $this->router->routes = array(); - $this->router->connect('/posts/:id::title'); - $this->assertEqual($this->router->routes[0][2], array('id', 'title')); - $this->assertEqual($this->router->routes[0][1], '#^/posts(?:/([^\/]+))?(?:\\:([^\/]+))?[\/]*$#'); - + foreach (array(':', '@', ';', '$', '-') as $delim) { + $this->router->routes = array(); + $this->router->connect('/posts/:id'.$delim.':title'); + $this->assertEqual($this->router->routes[0][2], array('id', 'title')); + $this->assertEqual($this->router->routes[0][1], '#^/posts(?:/([^\/]+))?(?:'.preg_quote($delim, '#').'([^\/]+))?[\/]*$#'); + } + $this->router->routes = array(); $this->router->connect('/posts/:id::title/:year'); $this->assertEqual($this->router->routes[0][2], array('id', 'title', 'year'));