mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUGFIX Type-safe checks for Controller::join_links(), allowing arguments with a value of "0"
This commit is contained in:
parent
46a3bbf7ba
commit
f9323b398c
@ -572,7 +572,8 @@ class Controller extends RequestHandler implements TemplateGlobalProvider {
|
||||
list($arg, $suffix) = explode('?',$arg,2);
|
||||
$querystrings[] = $suffix;
|
||||
}
|
||||
if($arg) {
|
||||
if((is_string($arg) && $arg) || is_numeric($arg)) {
|
||||
$arg = (string)$arg;
|
||||
if($result && substr($result,-1) != '/' && $arg[0] != '/') $result .= "/$arg";
|
||||
else $result .= (substr($result, -1) == '/' && $arg[0] == '/') ? ltrim($arg, '/') : $arg;
|
||||
}
|
||||
|
@ -108,6 +108,9 @@ class ControllerTest extends FunctionalTest {
|
||||
|
||||
/* If there are multiple, it takes the last one */
|
||||
$this->assertEquals("my-page?arg=var#second-section", Controller::join_links("my-page#subsection", "?arg=var", "#second-section"));
|
||||
|
||||
/* Does type-safe checks for zero value */
|
||||
$this->assertEquals("my-page/0", Controller::join_links("my-page", 0));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user