Skip to content

Commit 67ca02c

Browse files
committed
Change Server directory listing to not show ACL and .meta files.
1 parent e4c8885 commit 67ca02c

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

src/Server.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,10 @@ private function handle(string $method, string $path, $contents, $request): Resp
212212
$filename = $this->guid();
213213
}
214214
// FIXME: make this list complete for at least the things we'd expect (turtle, n3, jsonld, ntriples, rdf);
215-
// FIXME: if no content type was passed, we should reject the request according to the spec;
216-
217215
switch ($contentType) {
216+
case '':
217+
// FIXME: if no content type was passed, we should reject the request according to the spec;
218+
break;
218219
case "text/plain":
219220
$filename .= ".txt";
220221
break;
@@ -607,11 +608,17 @@ private function listDirectoryAsTurtle($path)
607608
foreach ($listContents as $item) {
608609
switch($item['type']) {
609610
case "file":
610-
$filename = "<" . rawurlencode($item['basename']) . ">";
611-
$turtle[$filename] = array(
612-
"a" => array("ldp:Resource")
613-
);
614-
$turtle["<>"]['ldp:contains'][] = $filename;
611+
// ACL and meta files should not be listed in directory overview
612+
if (
613+
$item['basename'] !== '.meta'
614+
&& in_array($item['extension'], ['acl', 'meta']) === false
615+
) {
616+
$filename = "<" . rawurlencode($item['basename']) . ">";
617+
$turtle[$filename] = array(
618+
"a" => array("ldp:Resource")
619+
);
620+
$turtle["<>"]['ldp:contains'][] = $filename;
621+
}
615622
break;
616623
case "dir":
617624
// FIXME: we have a trailing slash here to please the test suits, but it probably should also pass without it since we are a Container.

0 commit comments

Comments
 (0)