Skip to content

Commit f71e582

Browse files
committed
Added extra check so that only HTML files are handled with care
The hack will only work when it's a HTML file that is returned as the representation for the root resource
1 parent 84e856c commit f71e582

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/handlers/allow.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,13 @@ function allow (mode, checkPermissionsForDirectory) {
5757
// This is a hack to make NSS check the ACL for representation that is served for root (if any)
5858
// See https://github.com/solid/node-solid-server/issues/1063 for more info
5959
const representationUrl = await ldp.resourceMapper.getRepresentationUrlForResource(resourceUrl)
60-
req.acl = ACL.createFromLDPAndRequest(representationUrl, ldp, req)
61-
const representationIsAllowed = await req.acl.can(userId, mode)
62-
if (representationIsAllowed) {
63-
return next()
60+
if (representationUrl.endsWith('index.html')) {
61+
// We ONLY want to do this when the representation we return is a HTML file
62+
req.acl = ACL.createFromLDPAndRequest(representationUrl, ldp, req)
63+
const representationIsAllowed = await req.acl.can(userId, mode)
64+
if (representationIsAllowed) {
65+
return next()
66+
}
6467
}
6568
}
6669
const error = await req.acl.getError(userId, mode)

0 commit comments

Comments
 (0)