Skip to content

Commit 6f35a5a

Browse files
committed
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 go-gitea#3516. Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
1 parent 0da02b9 commit 6f35a5a

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

release-notes/8.0.0/fix/3562.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed a bug where subscribing to or unsubscribing from an issue in a repository with no code produced an internal server error.

routers/web/repo/issue_watch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func IssueWatch(ctx *context.Context) {
4646
return
4747
}
4848

49-
watch, err := strconv.ParseBool(ctx.Req.PostForm.Get("watch"))
49+
watch, err := strconv.ParseBool(ctx.Req.PostFormValue("watch"))
5050
if err != nil {
5151
ctx.ServerError("watch is not bool", err)
5252
return

0 commit comments

Comments
 (0)