This repository was archived by the owner on Nov 25, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,7 @@ function testPermission($numPerm){
87
87
$ numPerm = $ numPerm & self ::MASK ;
88
88
if (($ this ->value !== 0 ) && $ numPerm === 0 ) return false ;
89
89
if (($ this ->value === 0 ) && $ numPerm === self ::DENY ) return true ;
90
+ if ( ($ this ->value & self ::DENY ) === self ::DENY ) return false ;
90
91
return (($ this ->value & $ numPerm ) === $ numPerm );
91
92
}
92
93
else {
Original file line number Diff line number Diff line change @@ -110,19 +110,25 @@ function copyMask($mask){
110
110
*/
111
111
function match ($ test , $ permission ){
112
112
// Check if a path has the given permission
113
-
114
113
$ 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
+
116
122
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 ){
119
124
return $ permObject ->testPermission ($ permission );
120
125
}
121
126
}
122
127
// test is not under a defined permission, check if it needs traversal
123
128
foreach ($ pathes as $ path => $ permObject ){
124
129
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 ;
126
132
return $ permObject ->testPermission ($ permission );
127
133
}
128
134
}
You can’t perform that action at this time.
0 commit comments