BUGFIX: Fixed Controller::join_links() to properly handle multiple consecutive slashes.

From: Andrew Short <andrewjshort@gmail.com>

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@88494 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Andrew Short 2009-10-11 00:07:15 +00:00 committed by Sam Minnee
parent e533719d06
commit c1c7973b95
2 changed files with 7 additions and 1 deletions

View File

@ -559,7 +559,7 @@ class Controller extends RequestHandler {
}
if($arg) {
if($result && substr($result,-1) != '/' && $arg[0] != '/') $result .= "/$arg";
else $result .= $arg;
else $result .= (substr($result, -1) == '/' && $arg[0] == '/') ? ltrim($arg, '/') : $arg;
}
}

6
tests/ControllerTest.php Normal file → Executable file
View File

@ -96,6 +96,12 @@ class ControllerTest extends FunctionalTest {
/* Note, however, that it doesn't deal with duplicates very well. */
$this->assertEquals("admin/crm?flush=1&flush=1", Controller::join_links("admin/crm?flush=1", "?flush=1"));
$this->assertEquals (
'admin/action', Controller::join_links('admin/', '/', '/action'), 'Test that multiple slashes are trimmed.'
);
$this->assertEquals('/admin/action', Controller::join_links('/admin', 'action'));
}
}