diff options
author | Robin Appelman <icewind@owncloud.com> | 2013-01-15 14:57:23 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2013-01-15 14:57:23 +0100 |
commit | 9bf367e7f803d6968dc2c639624ce191d538a5bc (patch) | |
tree | 5ef8bec79c46d548d198ca87bbbc9b16974bb5a5 /lib/helper.php | |
parent | 3a9ec452729bf9b6a51d36750b095d9ef80a5f7e (diff) | |
parent | bb9cc227c2583adc6b51a1f6d75a9fc8333836b9 (diff) | |
download | nextcloud-server-9bf367e7f803d6968dc2c639624ce191d538a5bc.tar.gz nextcloud-server-9bf367e7f803d6968dc2c639624ce191d538a5bc.zip |
merge master into filesystem
Diffstat (limited to 'lib/helper.php')
-rw-r--r-- | lib/helper.php | 28 |
1 files changed, 4 insertions, 24 deletions
diff --git a/lib/helper.php b/lib/helper.php index b25ec01036a..7aede047974 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -625,37 +625,17 @@ class OC_Helper { return $newpath; } - /* - * checks if $sub is a subdirectory of $parent + /** + * @brief Checks if $sub is a subdirectory of $parent * * @param string $sub * @param string $parent * @return bool */ public static function issubdirectory($sub, $parent) { - if($sub == null || $sub == '' || $parent == null || $parent == '') { - return false; - } - $realpath_sub = realpath($sub); - $realpath_parent = realpath($parent); - if(($realpath_sub == false && substr_count($realpath_sub, './') != 0) || ($realpath_parent == false && substr_count($realpath_parent, './') != 0)) { //it checks for both ./ and ../ - return false; - } - if($realpath_sub && $realpath_sub != '' && $realpath_parent && $realpath_parent != '') { - if(substr($realpath_sub, 0, strlen($realpath_parent)) == $realpath_parent) { - return true; - } - }else{ - if(substr($sub, 0, strlen($parent)) == $parent) { - return true; - } + if (strpos(realpath($sub), realpath($parent)) === 0) { + return true; } - /*echo 'SUB: ' . $sub . "\n"; - echo 'PAR: ' . $parent . "\n"; - echo 'REALSUB: ' . $realpath_sub . "\n"; - echo 'REALPAR: ' . $realpath_parent . "\n"; - echo substr($realpath_sub, 0, strlen($realpath_parent)); - exit;*/ return false; } |