From e05c6cd83fb35ac2f25234147309776f39fb2556 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 24 Feb 2011 16:43:13 -0500 Subject: [PATCH] Fixing issue where actions starting with a prefix but not followed by an _ would get mangled when going through router::url(). Fixes #1556 --- cake/libs/router.php | 2 +- cake/tests/cases/libs/router.test.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cake/libs/router.php b/cake/libs/router.php index 622dae829..86e77daae 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -822,7 +822,7 @@ class Router { } elseif (isset($url[$prefix]) && !$url[$prefix]) { unset($url[$prefix]); } - if (isset($url[$prefix]) && strpos($url['action'], $prefix) === 0) { + if (isset($url[$prefix]) && strpos($url['action'], $prefix . '_') === 0) { $url['action'] = substr($url['action'], strlen($prefix) + 1); } } diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index 8346dfec8..0d199655d 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -1513,6 +1513,10 @@ class RouterTest extends CakeTestCase { $result = Router::url(array('action' => 'protected_edit', 1, 'protected' => true)); $expected = '/protected/images/edit/1'; $this->assertEqual($result, $expected); + + $result = Router::url(array('action' => 'protectededit', 1, 'protected' => true)); + $expected = '/protected/images/protectededit/1'; + $this->assertEqual($result, $expected); $result = Router::url(array('action' => 'edit', 1, 'protected' => true)); $expected = '/protected/images/edit/1';