X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=handlers%2F30_edit.sh;h=6d4e1eac12bd7c1359b7b1a95ad9bd19dcfa11b4;hb=4176213eafe0118f19fc492b3bfa5f23efa4acb0;hp=315b5c9b996125ac70f6447a86a02242aa514fd4;hpb=83e0af894f4b236b13df61e96ac774de8c2605a5;p=shellwiki diff --git a/handlers/30_edit.sh b/handlers/30_edit.sh index 315b5c9..6d4e1ea 100755 --- a/handlers/30_edit.sh +++ b/handlers/30_edit.sh @@ -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