Skip to content

Commit

Permalink
fix path check where path is same but longer than container. fixes #30
Browse files Browse the repository at this point in the history
  • Loading branch information
splitbrain committed Aug 10, 2017
1 parent 2b85f30 commit 0f0a264
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions _test/helper.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,8 @@ public function test_isInPath() {
$this->assertFalse($helper->isInPath('/var/www/foo', '/var/www/foo'));
$this->assertFalse($helper->isInPath('/var/www/foo/', '/var/www/foo'));
$this->assertFalse($helper->isInPath('/var/www/foo/bar/../', '/var/www/foo'));

// https://github.com/cosmocode/dokuwiki-plugin-farmer/issues/30
$this->assertFalse($helper->isInPath('/var/lib/dokuwiki.animals', '/var/lib/dokuwiki'));
}
}
4 changes: 2 additions & 2 deletions helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public function getAllAnimals() {
* @return bool
*/
public function isInPath($path, $container) {
$path = fullpath($path);
$container = fullpath($container);
$path = fullpath($path).'/';
$container = fullpath($container).'/';
if($path == $container) return false;
return (strpos($path, $container) === 0);
}
Expand Down

0 comments on commit 0f0a264

Please sign in to comment.