From f9323b398c3f74522158bf64f41aa6300ec0ba3c Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 8 Mar 2012 21:41:17 +0100 Subject: [PATCH] BUGFIX Type-safe checks for Controller::join_links(), allowing arguments with a value of "0" --- control/Controller.php | 3 ++- tests/control/ControllerTest.php | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/control/Controller.php b/control/Controller.php index b8882d4f4..0f7b124e3 100644 --- a/control/Controller.php +++ b/control/Controller.php @@ -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; } diff --git a/tests/control/ControllerTest.php b/tests/control/ControllerTest.php index 57f9ccd3d..6808c9501 100644 --- a/tests/control/ControllerTest.php +++ b/tests/control/ControllerTest.php @@ -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)); } /**