Don't read file contents of inaccessible pages

This commit is contained in:
Daniel Rudolf 2015-10-01 17:22:14 +02:00
parent 95db5ba1a1
commit 45815e2c6d

View file

@ -717,6 +717,13 @@ class Pico
}
$id = substr($file, strlen($this->getConfig('content_dir')), -strlen($this->getConfig('content_ext')));
// drop inaccessible pages (e.g. drop "sub.md" if "sub/index.md" exists)
$conflictFile = $this->getConfig('content_dir') . $id . '/index' . $this->getConfig('content_ext');
if (in_array($conflictFile, $files, true)) {
continue;
}
$url = $this->getPageUrl($id);
if ($file != $this->requestFile) {
$rawContent = file_get_contents($file);
@ -726,13 +733,6 @@ class Pico
$meta = &$this->meta;
}
// drop inaccessible pages (e.g. drop "sub.md" if "sub/index.md" exists)
if (substr($id, -6) === '/index') {
unset($pages[dirname($id)]);
} elseif (isset($pages[$id . '/index'])) {
continue;
}
// build page data
// title, description, author and date are assumed to be pretty basic data
// everything else is accessible through $page['meta']