Przeglądaj źródła

Don't read file contents of inaccessible pages

Daniel Rudolf 9 lat temu
rodzic
commit
45815e2c6d
1 zmienionych plików z 7 dodań i 7 usunięć
  1. 7 7
      lib/Pico.php

+ 7 - 7
lib/Pico.php

@@ -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']