Permalink
Browse files

BUGFIX Type-safe checks for Controller::join_links(), allowing argume…

…nts with a value of "0"
  • Loading branch information...
1 parent 46a3bbf commit f9323b398c3f74522158bf64f41aa6300ec0ba3c @chillu chillu committed Mar 8, 2012
Showing with 5 additions and 1 deletion.
  1. +2 −1 control/Controller.php
  2. +3 −0 tests/control/ControllerTest.php
View
@@ -572,7 +572,8 @@ static function join_links() {
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 @@ function testJoinLinks() {
/* 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));
}
/**

0 comments on commit f9323b3

Please sign in to comment.