Bladeren bron

plugins/base: allow redirect param to be a form param

master
Simon Ser 4 jaren geleden
bovenliggende
commit
f6959346ee
Geen bekende sleutel gevonden voor deze handtekening in de database GPG sleutel-ID: FDE7BE0E88F5E48
1 gewijzigde bestanden met toevoegingen van 11 en 7 verwijderingen
  1. +11
    -7
      plugins/base/routes.go

+ 11
- 7
plugins/base/routes.go Bestand weergeven

@@ -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) {


Laden…
Annuleren
Opslaan