From 6f35a5ab904325027be24c98bcf6fdd9f9ddce54 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Tue, 30 Apr 2024 11:21:41 +0200 Subject: [PATCH] Fix Issue watching / unwatching on the web ui When subscribing or unsubscribing to/from an issue on the web ui, the request was posted to a route handled by `repo.IssueWatch`. This function used `ctx.Req.PostForm.Get()`, erroneously. `request.PostForm` is *only* available if `request.ParseForm()` has been called before it. The function in question did not do that. Under some circumstances, something, somewhere did end up calling `ParseForm()`, but not in every scenario. Since we do not need to check for multiple values, the easiest fix here is to use `ctx.Req.PostFormValue`, which will call `ParseForm()` if necessary. Fixes #3516. Signed-off-by: Gergely Nagy --- release-notes/8.0.0/fix/3562.md | 1 + routers/web/repo/issue_watch.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 release-notes/8.0.0/fix/3562.md diff --git a/release-notes/8.0.0/fix/3562.md b/release-notes/8.0.0/fix/3562.md new file mode 100644 index 0000000000..8099056205 --- /dev/null +++ b/release-notes/8.0.0/fix/3562.md @@ -0,0 +1 @@ +Fixed a bug where subscribing to or unsubscribing from an issue in a repository with no code produced an internal server error. diff --git a/routers/web/repo/issue_watch.go b/routers/web/repo/issue_watch.go index 8b033f3b17..6799bf8eb2 100644 --- a/routers/web/repo/issue_watch.go +++ b/routers/web/repo/issue_watch.go @@ -46,7 +46,7 @@ func IssueWatch(ctx *context.Context) { return } - watch, err := strconv.ParseBool(ctx.Req.PostForm.Get("watch")) + watch, err := strconv.ParseBool(ctx.Req.PostFormValue("watch")) if err != nil { ctx.ServerError("watch is not bool", err) return