summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVivien Kraus <vivien@planete-kraus.eu>2021-06-26 23:15:46 +0200
committerVivien Kraus <vivien@planete-kraus.eu>2021-06-27 00:17:52 +0200
commit7672491a3374d0dce45a0a9db2ab2cc4a7dd2944 (patch)
tree3980a7e538c73feeb986f173d1ec3da745949b6b
parent1b7a485bbd05802432539984f3df078b5b8134ac (diff)
ACL: handle non-existing resources
-rw-r--r--src/scm/webid-oidc/server/resource/wac.scm11
-rw-r--r--tests/acl.scm3
2 files changed, 13 insertions, 1 deletions
diff --git a/src/scm/webid-oidc/server/resource/wac.scm b/src/scm/webid-oidc/server/resource/wac.scm
index e482ce4..b9959f9 100644
--- a/src/scm/webid-oidc/server/resource/wac.scm
+++ b/src/scm/webid-oidc/server/resource/wac.scm
@@ -183,7 +183,16 @@
(with-session
(lambda (content-type contained static-content create delete)
(define (wac-check-recursive path check-default?)
- (receive (main-etag auxiliary) (read-path path)
+ (receive (main-etag auxiliary)
+ (with-exception-handler
+ (lambda (error)
+ (unless (path-not-found? error)
+ (raise-exception error))
+ (values #f '()))
+ (lambda ()
+ (read-path path))
+ #:unwind? #t
+ #:unwind-for-type &path-not-found)
(let ((acl-etag (assoc-ref auxiliary acl-aux)))
(if acl-etag
(with-rdf-source
diff --git a/tests/acl.scm b/tests/acl.scm
index b582b17..4249e6e 100644
--- a/tests/acl.scm
+++ b/tests/acl.scm
@@ -53,6 +53,7 @@
;; /docs/ can only be updated by Alice and the public can list
;; /docs/file1 can only be updated by Alice, but public
;; /docs/file2 same, but authenticated
+ ;; /fiction/file does not exist, so /#default applies
;; /private-docs/ private to Alice, no ACL
;; /private-docs/file1 no ACL (so, readable by the FBI as inherited in /)
;; /private/docs/file2 no ACL (so, not readable by the FBI)
@@ -179,6 +180,7 @@
;; /docs/ RWC R R R
;; /docs/file1 RWC R R R
;; /docs/file2 RWC R R X
+ ;; /fiction/file RWC X X X
;; /private-docs/ RWC X X X
;; /private-docs/file1 RWC X RW X
;; /private-docs/file2 RWC X X X
@@ -244,6 +246,7 @@
(run-test "/docs/" RWC R R R)
(run-test "/docs/file1" RWC R R R)
(run-test "/docs/file2" RWC R R X)
+ (run-test "/fiction/file" RWC X X X)
(run-test "/private-docs/" RWC X X X)
(run-test "/private-docs/file1" RWC X RW X)
(run-test "/private-docs/file2" RWC X X X)))))))))