aboutsummaryrefslogtreecommitdiff
path: root/ennu.el
diff options
context:
space:
mode:
authorArun Isaac2020-03-13 21:29:16 +0530
committerArun Isaac2020-03-13 21:29:16 +0530
commitd6c776b618f8d84f28eb69aa9113ffce599cad9b (patch)
treee7366285523cec371001f84c3a03911e28e43daf /ennu.el
parentc3c4a17b09f695ed5474918747238ffc70cde5d9 (diff)
downloadennum-d6c776b618f8d84f28eb69aa9113ffce599cad9b.tar.gz
ennum-d6c776b618f8d84f28eb69aa9113ffce599cad9b.tar.lz
ennum-d6c776b618f8d84f28eb69aa9113ffce599cad9b.zip
Deny requests to all html files except index.html.
* ennu.el (ennu-server-start): Deny requests to all html files except index.html.
Diffstat (limited to 'ennu.el')
-rw-r--r--ennu.el13
1 files changed, 9 insertions, 4 deletions
diff --git a/ennu.el b/ennu.el
index 69e8a93..5cd1d1a 100644
--- a/ennu.el
+++ b/ennu.el
@@ -486,10 +486,15 @@ as keys. Keys are compared using `equal'."
(setq httpd-root (expand-file-name (ennu-setting :output-directory)
(ennu-setting :working-directory)))
(defun httpd/ (proc uri-path query request)
- (let ((uri-path (httpd-unhex uri-path)))
- (pcase (httpd-status (httpd-gen-path uri-path))
- (200 (httpd-serve-root proc httpd-root uri-path request))
- (_ (httpd-serve-root proc httpd-root (concat uri-path ".html") request)))))
+ (let ((uri-path (httpd-unhex uri-path))
+ (file-path (httpd-gen-path uri-path)))
+ (cond
+ ((and (not (string= (file-name-nondirectory file-path) "index.html"))
+ (string= (file-name-extension file-path) "html"))
+ (httpd-error proc 404))
+ ((= (httpd-status file-path) 200)
+ (httpd-serve-root proc httpd-root uri-path request))
+ (t (httpd-serve-root proc httpd-root (concat uri-path ".html") request)))))
(httpd-start))
(defun ennu-server-stop ()