Fix manage handlers ignoring multipart form bodies
The /manage page posts with FormData, i.e. multipart/form-data, but the edit, delete, tags, restore and empty-trash handlers parsed with r.ParseForm, which only reads urlencoded bodies. So every field came back empty: delete returned 200 with deleted:0 and moved nothing, edits saved nothing — while curl -d (urlencoded) worked, which is why tests and manual checks missed it. Parse with ParseMultipartForm (tolerating ErrNotMultipart so urlencoded still works), via a shared parseForm helper used by all manage handlers. handleUpload already did this. Also stop the UI reporting deleted:0 / updated:0 as success, and add a multipart regression test.
This commit is contained in:
1 parent
25384d3f3b
commit
bf75c9fe8e
4 files changed
+75
-9
No files matched your search
@@ -135,7 +135,7 @@ func (s *Server) handleRestore(w http.ResponseWriter, r *http.Request) {
|
||||
if s.rejectCrossSite(w, r) {
|
||||
return
|
||||
}
|
||||
if err := r.ParseForm(); err != nil {
|
||||
if err := parseForm(r); err != nil {
|
||||
http.Error(w, "bad request", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
@@ -175,7 +175,7 @@ func (s *Server) handleEmptyTrash(w http.ResponseWriter, r *http.Request) {
|
||||
if s.rejectCrossSite(w, r) {
|
||||
return
|
||||
}
|
||||
if err := r.ParseForm(); err != nil {
|
||||
if err := parseForm(r); err != nil {
|
||||
http.Error(w, "bad request", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user