@@ -132,7 +132,7 @@ private function getUserGrants($resourcePath, $webId) {
132132 $ acl = $ this ->filesystem ->read ($ aclPath );
133133
134134 $ graph = new \EasyRdf_Graph ();
135- $ graph ->parse ($ acl , Format::TURTLE , $ this ->baseUrl . " / " );
135+ $ graph ->parse ($ acl , Format::TURTLE , $ this ->getAclBase ( $ aclPath ) );
136136
137137 // error_log("GET GRANTS for $webId");
138138
@@ -172,7 +172,7 @@ private function getOriginGrants($resourcePath, $origin) {
172172 $ acl = $ this ->filesystem ->read ($ aclPath );
173173
174174 $ graph = new \EasyRdf_Graph ();
175- $ graph ->parse ($ acl , Format::TURTLE , $ this ->baseUrl . " / " );
175+ $ graph ->parse ($ acl , Format::TURTLE , $ this ->getAclBase ( $ aclPath ) );
176176
177177 // error_log("GET GRANTS for $origin");
178178
@@ -205,17 +205,18 @@ private function getOriginGrants($resourcePath, $origin) {
205205 }
206206
207207 private function getAclPath ($ path ) {
208+ $ path = $ this ->normalizePath ($ path );
208209 // get the filename from the request
209210 $ filename = basename ($ path );
210211 $ path = dirname ($ path );
211212
212- // error_log("REQUESTED PATH: $path");
213- // error_log("REQUESTED FILE: $filename");
213+ error_log ("REQUESTED PATH: $ path " );
214+ error_log ("REQUESTED FILE: $ filename " );
214215
215216 $ aclOptions = array (
216- $ path .'/ ' .$ filename .'.acl ' ,
217- $ path .'/ ' .$ filename .'/.acl ' ,
218- $ path .'/.acl '
217+ $ this -> normalizePath ( $ path .'/ ' .$ filename .'.acl ' ) ,
218+ $ this -> normalizePath ( $ path .'/ ' .$ filename .'/.acl ' ) ,
219+ $ this -> normalizePath ( $ path .'/.acl ' ),
219220 );
220221
221222 foreach ($ aclOptions as $ aclPath ) {
@@ -231,7 +232,9 @@ private function getAclPath($path) {
231232 // check for acl:default predicate, if not found, continue searching up the directory tree
232233 return $ this ->getParentAcl ($ path );
233234 }
234-
235+ private function normalizePath ($ path ) {
236+ return preg_replace ("|//| " , "/ " , $ path );
237+ }
235238 private function getParentAcl ($ path ) {
236239 //error_log("GET PARENT ACL $path");
237240 if ($ this ->filesystem ->has ($ path .'/.acl ' )) {
@@ -375,6 +378,9 @@ private function grantToWac($grant) {
375378 return strtolower (explode ("# " , $ grant )[1 ]); // http://www.w3.org/ns/auth/acl#Read => read
376379 }
377380
381+ private function getAclBase ($ aclPath ) {
382+ return $ this ->baseUrl . $ this ->normalizePath (dirname ($ aclPath ) . "/ " );
383+ }
378384 private function getPublicGrants ($ resourcePath ) {
379385 $ aclPath = $ this ->getAclPath ($ resourcePath );
380386 if (!$ aclPath ) {
@@ -385,7 +391,8 @@ private function getPublicGrants($resourcePath) {
385391
386392 $ graph = new \EasyRdf_Graph ();
387393
388- $ graph ->parse ($ acl , Format::TURTLE , $ this ->baseUrl . "/ " );
394+ error_log ("PARSE ACL from $ aclPath with base " . $ this ->getAclBase ($ aclPath ));
395+ $ graph ->parse ($ acl , Format::TURTLE , $ this ->getAclBase ($ aclPath ));
389396
390397 $ grants = array ();
391398
0 commit comments