From d252df4b98c0af82ea76a3ba9abc409138d8cb93 Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Thu, 19 Nov 2015 04:48:22 +0100 Subject: [PATCH] Throw RuntimeException on invalid content dirs --- CHANGELOG.md | 1 + lib/Pico.php | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 912e766..991b2ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Released: - want to parse the contents of a page, use the `content` filter instead * [Changed] Improve documentation * [Changed] Improve table styling in default theme +* [Changed] Throw a RuntimeException when the `content` dir isn't accessible * [Changed] Reuse `ParsedownExtra` object; new `onParsedownRegistration` event * [Fixed] `PicoDeprecated`: Sanitize `content_dir` and `base_url` options when reading `config.php` in Picos root dir diff --git a/lib/Pico.php b/lib/Pico.php index 443e557..3089290 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -266,7 +266,8 @@ class Pico * meta headers, processes Markdown, does Twig processing and returns * the rendered contents. * - * @return string rendered Pico contents + * @return string rendered Pico contents + * @throws RuntimeException thrown when a not recoverable error occurs */ public function run() { @@ -281,6 +282,11 @@ class Pico $this->loadConfig(); $this->triggerEvent('onConfigLoaded', array(&$this->config)); + // check content dir + if (!is_dir($this->getConfig('content_dir'))) { + throw new RuntimeException('Invalid content directory "' . $this->getConfig('content_dir') . '"'); + } + // evaluate request url $this->evaluateRequestUrl(); $this->triggerEvent('onRequestUrl', array(&$this->requestUrl));