소스 검색

Improve detection of hidden files to serve 404 contents instead

Follow-up to 9b72b5c316b38129952a4d59af05a0138ca1a15a
Daniel Rudolf 8 년 전
부모
커밋
1f35346f53
1개의 변경된 파일2개의 추가작업 그리고 5개의 파일을 삭제
  1. 2 5
      lib/Pico.php

+ 2 - 5
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));