From 1f35346f534a43ed0eb78a2f610f901667f81bcc Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Mon, 12 Dec 2016 16:37:20 +0100 Subject: [PATCH] Improve detection of hidden files to serve 404 contents instead Follow-up to 9b72b5c316b38129952a4d59af05a0138ca1a15a --- lib/Pico.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/Pico.php b/lib/Pico.php index 1644209..d2f1b2a 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -344,11 +344,8 @@ class Pico // load raw file content $this->triggerEvent('onContentLoading', array(&$this->requestFile)); - if ( - file_exists($this->requestFile) - && (basename($this->requestFile) !== '404' . $this->getConfig('content_ext')) - && !preg_match('/(?:^|\/)_/', $this->requestFile) - ) { + $hiddenFileRegex = '/(?:^|\/)(?:_|404' . preg_quote($this->getConfig('content_ext'), '/') . '$)/'; + if (file_exists($this->requestFile) && !preg_match($hiddenFileRegex, $this->requestFile)) { $this->rawContent = $this->loadFileContent($this->requestFile); } else { $this->triggerEvent('on404ContentLoading', array(&$this->requestFile));