aboutsummaryrefslogtreecommitdiff
path: root/plugins/base
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-03-27 10:27:37 +0100
committerSimon Ser <contact@emersion.fr>2020-03-27 10:27:37 +0100
commitf6959346ee75ba6aa97f86850bc222404372db38 (patch)
tree0a5c8e23ad34b6bc05d5a7a1d36ca900b05d4512 /plugins/base
parent9b804005b445d54114a1ddeb3cb6b22a872911d2 (diff)
downloadalps-f6959346ee75ba6aa97f86850bc222404372db38.tar.gz
alps-f6959346ee75ba6aa97f86850bc222404372db38.zip
plugins/base: allow redirect param to be a form param
Diffstat (limited to 'plugins/base')
-rw-r--r--plugins/base/routes.go18
1 files changed, 11 insertions, 7 deletions
diff --git a/plugins/base/routes.go b/plugins/base/routes.go
index 1ea611d..689fca4 100644
--- a/plugins/base/routes.go
+++ b/plugins/base/routes.go
@@ -653,6 +653,13 @@ func handleEdit(ctx *koushin.Context) error {
return handleCompose(ctx, &msg, &composeOptions{Draft: &sourcePath})
}
+func formOrQueryParam(ctx *koushin.Context, k string) string {
+ if v := ctx.FormValue(k); v != "" {
+ return v
+ }
+ return ctx.QueryParam(k)
+}
+
func handleMove(ctx *koushin.Context) error {
mboxName, err := url.PathUnescape(ctx.Param("mbox"))
if err != nil {
@@ -668,10 +675,7 @@ func handleMove(ctx *koushin.Context) error {
return echo.NewHTTPError(http.StatusBadRequest, err)
}
- to := ctx.FormValue("to")
- if to == "" {
- to = ctx.QueryParam("to")
- }
+ to := formOrQueryParam(ctx, "to")
if to == "" {
return echo.NewHTTPError(http.StatusBadRequest, "missing 'to' form parameter")
}
@@ -696,7 +700,7 @@ func handleMove(ctx *koushin.Context) error {
return err
}
- if path := ctx.QueryParam("next"); path != "" {
+ if path := formOrQueryParam(ctx, "next"); path != "" {
return ctx.Redirect(http.StatusFound, path)
}
return ctx.Redirect(http.StatusFound, fmt.Sprintf("/mailbox/%v", url.PathEscape(to)))
@@ -747,7 +751,7 @@ func handleDelete(ctx *koushin.Context) error {
return err
}
- if path := ctx.QueryParam("next"); path != "" {
+ if path := formOrQueryParam(ctx, "next"); path != "" {
return ctx.Redirect(http.StatusFound, path)
}
return ctx.Redirect(http.StatusFound, fmt.Sprintf("/mailbox/%v", url.PathEscape(mboxName)))
@@ -819,7 +823,7 @@ func handleSetFlags(ctx *koushin.Context) error {
return err
}
- if path := ctx.QueryParam("next"); path != "" {
+ if path := formOrQueryParam(ctx, "next"); path != "" {
return ctx.Redirect(http.StatusFound, path)
}
if len(uids) != 1 || (op == imap.RemoveFlags && len(flags) == 1 && flags[0] == imap.SeenFlag) {