diff --git a/router/upload.go b/router/upload.go index 9aa650d5..a51f8da4 100644 --- a/router/upload.go +++ b/router/upload.go @@ -255,6 +255,10 @@ func (f *UploadForm) ExtractEditInfo(r *http.Request) error { return ErrInvalidTorrentCategory } + if !categories.CategoryExists(f.Category) { + return ErrInvalidTorrentCategory + } + f.CategoryID = CatID f.SubCategoryID = SubCatID } else { @@ -289,4 +293,4 @@ func NewUploadForm(params ...string) (uploadForm UploadForm) { uploadForm.Description = "Description" } return -} +} \ No newline at end of file diff --git a/router/view_torrent_handler.go b/router/view_torrent_handler.go index 803e6b4b..b5cc488d 100644 --- a/router/view_torrent_handler.go +++ b/router/view_torrent_handler.go @@ -134,13 +134,12 @@ func TorrentEditUserPanel(w http.ResponseWriter, r *http.Request) { messages:= msg.GetMessages(r) currentUser := GetUser(r) if userPermission.CurrentOrAdmin(currentUser, torrent.UploaderID) { - torrentJson := torrent.ToJSON() uploadForm := NewUploadForm() - uploadForm.Name = torrentJson.Name - uploadForm.Category = torrentJson.Category + "_" + torrentJson.SubCategory - uploadForm.Status = torrentJson.Status - uploadForm.WebsiteLink = string(torrentJson.WebsiteLink) - uploadForm.Description = string(torrentJson.Description) + uploadForm.Name = torrent.Name + uploadForm.Category = strconv.Itoa(torrent.Category) + "_" + strconv.Itoa(torrent.SubCategory) + uploadForm.Remake = torrent.Status == model.TorrentStatusRemake + uploadForm.WebsiteLink = string(torrent.WebsiteLink) + uploadForm.Description = string(torrent.Description) htv := UserTorrentEdVbs{NewCommonVariables(r), uploadForm, messages.GetAllErrors(), messages.GetAllInfos()} err := userTorrentEd.ExecuteTemplate(w, "index.html", htv) log.CheckError(err) @@ -162,6 +161,7 @@ func TorrentPostEditUserPanel(w http.ResponseWriter, r *http.Request) { } if !messages.HasErrors() { status := model.TorrentStatusNormal + uploadForm.Remake = r.FormValue(UploadFormRemake) == "on" if uploadForm.Remake { // overrides trusted status = model.TorrentStatusRemake } else if currentUser.IsTrusted() { @@ -205,4 +205,4 @@ func TorrentDeleteUserPanel(w http.ResponseWriter, r *http.Request) { } else { NotFoundHandler(w, r) } -} +} \ No newline at end of file