]> git.plutz.net Git - shellwiki/blobdiff - handlers/30_edit.sh
Separate file for attachment edit functions. Functions to move attached files.
[shellwiki] / handlers / 30_edit.sh
index 315b5c9b996125ac70f6447a86a02242aa514fd4..6d4e1eac12bd7c1359b7b1a95ad9bd19dcfa11b4 100755 (executable)
@@ -16,13 +16,22 @@ wiki_text() {
   fi
 }
 
+case $PATH_INFO in
+  */\[edit\]) : ;;
+  *) return 1 ;;
+esac
+
 edit_page="${PATH_INFO%\[edit\]}"
 edit_file="$_DATA/pages/$edit_page/#page.md"
 [ "$REQUEST_METHOD" = POST ] && edit_action="$(POST action)"
 
-if [ "$edit_page" = "$PATH_INFO" ]; then
-  unset edit_page edit_action edit_file
-  # END EDIT SCRIPT, continue in index.cgi
+if ! acl_write "$edit_page"; then
+  theme_error 403
+  return 0
+
+elif [ "$edit_action" = cancel ]; then
+  S_RELEASE "$edit_file"
+  REDIRECT "${_BASE}${PATH_INFO%\[edit\]}"
 
 elif [ "$edit_action" = update ]; then
   if  mkdir -p -- "${edit_file%/#page.md}" \
@@ -42,15 +51,7 @@ elif [ "$edit_action" = update ]; then
       -- "pages/$edit_page/#page.md"
   fi 1>&2
 
-  REDIRECT "${_BASE}${PATH_INFO%\[edit\]}"
-
-elif [ "$edit_action" = cancel ]; then
-  S_RELEASE "$edit_file"
-  REDIRECT "${_BASE}${PATH_INFO%\[edit\]}"
-
-elif ! acl_write "$edit_page"; then
-  theme_error 403
-  return 0
+  REDIRECT "${_BASE}${edit_page}"
 
 elif mkdir -p -- "${edit_file%/#page.md}" \
      && S_LOCK "$edit_file"; then