Skip to content

Commit 9512e48

Browse files
committed
whitespace fix + normalize paths
1 parent 71c260c commit 9512e48

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/WAC.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ public function isAllowed($request, $webId, $origin=false, $allowedOrigins=[]) {
5353
$uri = $request->getUri();
5454
$parentUri = $this->getParentUri($uri);
5555

56-
// @FIXME: $origin can be anything at this point, null, string, array, bool
57-
// This causes trouble downstream where an unchecked `parse_url($origin)['host'];` occurs
56+
// @FIXME: $origin can be anything at this point, null, string, array, bool
57+
// This causes trouble downstream where an unchecked `parse_url($origin)['host'];` occurs
5858

59-
foreach ($requestedGrants as $requestedGrant) {
59+
foreach ($requestedGrants as $requestedGrant) {
6060
switch ($requestedGrant['type']) {
6161
case "resource":
6262
if ($this->isPublicGranted($requestedGrant['grants'], $uri)) {
@@ -141,9 +141,9 @@ private function isOriginGranted($requestedGrants, $uri, $origin, $allowedOrigin
141141
) {
142142
return true;
143143
}
144-
//error_log("REQUESTED GRANT: " . join(" or ", $requestedGrants) . " on $uri");
144+
// error_log("REQUESTED GRANT: " . join(" or ", $requestedGrants) . " on $uri");
145145
$grants = $this->getOriginGrants($uri, $origin);
146-
//error_log("GRANTED GRANTS for origin $origin: " . json_encode($grants));
146+
// error_log("GRANTED GRANTS for origin $origin: " . json_encode($grants));
147147
return $this->checkGrants($requestedGrants, $uri, $grants);
148148
}
149149

@@ -307,14 +307,13 @@ private function getAclPath($path) {
307307

308308
foreach ($aclOptions as $aclPath) {
309309
if (
310-
$this->filesystem->has($aclPath)
311-
&& $this->filesystem->read($aclPath) !== false
310+
$this->filesystem->has($aclPath) && $this->filesystem->read($aclPath) !== false
312311
) {
313312
return $aclPath;
314313
}
315314
}
316315

317-
//error_log("Seeking .acl from $path");
316+
// error_log("Seeking .acl from $path");
318317
// see: https://github.com/solid/web-access-control-spec#acl-inheritance-algorithm
319318
// check for acl:default predicate, if not found, continue searching up the directory tree
320319
return $this->getParentAcl($path);
@@ -323,10 +322,10 @@ private function normalizePath($path) {
323322
return preg_replace("|//|", "/", $path);
324323
}
325324
private function getParentAcl($path) {
326-
//error_log("GET PARENT ACL $path");
327-
if ($this->filesystem->has($path.'/.acl')) {
328-
//error_log("CHECKING ACL FILE ON $path/.acl");
329-
return $path . "/.acl";
325+
// error_log("GET PARENT ACL $path");
326+
if ($this->filesystem->has($this->normalizePath($path.'/.acl'))) {
327+
// error_log("CHECKING ACL FILE ON $path/.acl");
328+
return $this->normalizePath($path . "/.acl");
330329
}
331330
$parent = dirname($path);
332331
if ($parent == $path) {

0 commit comments

Comments
 (0)