BUGFIX Type-safe checks for Controller::join_links(), allowing arguments with a value of "0"

This commit is contained in:
Ingo Schommer 2012-03-08 21:41:17 +01:00
parent 46a3bbf7ba
commit f9323b398c
2 changed files with 5 additions and 1 deletions

View File

@ -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;
}

View File

@ -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));
}
/**