]> git.plutz.net Git - shellwiki/blobdiff - handlers/10_page.sh
avoid mishandling of pages (wrong 404 in particular)
[shellwiki] / handlers / 10_page.sh
index 186b705715231a31c290e5d66dbaac1fe58cb6c9..edb849ab24acb12b7ea644c8572768be404535f6 100755 (executable)
@@ -1,5 +1,7 @@
 #!/bin/sh
 
+. "$_EXEC/cgilite/file.sh"
+
 CACHE_AGE=${CACHE_AGE:-300}
 export MD_MACROS="$_EXEC/macros"
 export MD_HTML="${MD_HTML:-false}"
@@ -34,6 +36,8 @@ wiki() {
 
 case "${PATH_INFO}" in
   /"[.]"/*)
+    # usually some file related to theme
+    # let file server handle errors
     FILE "${_EXEC}/${PATH_INFO#/\[.\]}"
     return 0
     ;;
@@ -47,11 +51,18 @@ case "${PATH_INFO}" in
     theme_error 400
     return 0
     ;;
-  */\[*\]/*)
+  */\[*\]/*|*/\[*\])
+    # looks like some kind of handler
     return 1
     ;;
   */)
-    theme_page "${PATH_INFO}"
+    if [ ! "$(mdfile "$page")" ]; then
+      theme_error 404
+    elif ! acl_read "$page"; then
+      theme_error 403
+    else
+      theme_page "${PATH_INFO}"
+    fi
     return 0
     ;;
 esac