mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
e533719d06
commit
c1c7973b95
@ -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
6
tests/ControllerTest.php
Normal file → Executable 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'));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user