Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit c282ee0

Browse files
committed
Fix PermissionMask & checks
1 parent 5057146 commit c282ee0

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

core/src/core/classes/class.AJXP_Permission.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ function testPermission($numPerm){
8787
$numPerm = $numPerm & self::MASK;
8888
if (($this->value !== 0) && $numPerm === 0) return false;
8989
if (($this->value === 0) && $numPerm === self::DENY) return true;
90+
if ( ($this->value & self::DENY ) === self::DENY) return false;
9091
return (($this->value & $numPerm) === $numPerm);
9192
}
9293
else{

core/src/core/classes/class.AJXP_PermissionMask.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,25 @@ function copyMask($mask){
110110
*/
111111
function match($test, $permission){
112112
// Check if a path has the given permission
113-
114113
$pathes = $this->flattenTree();
115-
//print_r($pathes);
114+
115+
if(empty($test) || $test == "/" || $test == "/." || $test == "/..") {
116+
if(!count($pathes)) return true;
117+
if($permission == AJXP_Permission::READ) return true;
118+
else if($permission == AJXP_Permission::WRITE) return false;
119+
return true;
120+
}
121+
116122
foreach($pathes as $path => $permObject){
117-
if(strpos($test, $path) === 0){
118-
// var_dump("Test $test starts with existing path ".$path.":".$permObject);
123+
if(strpos($test, rtrim($path, "/")."/") === 0 || $test === $path){
119124
return $permObject->testPermission($permission);
120125
}
121126
}
122127
// test is not under a defined permission, check if it needs traversal
123128
foreach($pathes as $path => $permObject){
124129
if(strpos($path, $test) === 0 && !$permObject->denies()){
125-
// var_dump("Existing path starts with test ($test) >> ".$path.":".$permObject);
130+
if($permission == AJXP_Permission::READ) return true;
131+
else if($permission == AJXP_Permission::WRITE) return false;
126132
return $permObject->testPermission($permission);
127133
}
128134
}

0 commit comments

Comments
 (0)