Skip to content
Snippets Groups Projects
Commit bddf8c83 authored by Stephan Bosch's avatar Stephan Bosch
Browse files

Added mail-loop detection to the redirect action.

parent bb78d0b1
No related branches found
No related tags found
No related merge requests found
......@@ -108,7 +108,7 @@ Extensions and their implementation status:
fileinto: full
reject: full
envelope: full
encoded-character: planned (draft-ietf-sieve-3028bis)
encoded-character: planned (draft-ietf-sieve-3028bis)
Other RFCs/drafts:
subaddress: full
......@@ -120,7 +120,7 @@ Extensions and their implementation status:
imapflags: flag management works, but flags are not stored
copy: full
include: planned (* first leave out variables support)
variables: planned (* also amend previously implemented extensions)
variables: planned (* also amend previously implemented extensions)
body: planned
notify: planned (- lowest priority)
......
#include "lib.h"
#include "ioloop.h"
#include "str-sanitize.h"
#include "istream.h"
#include "istream-header-filter.h"
......@@ -14,6 +15,10 @@
#include <stdio.h>
/* Config */
#define CMD_REDIRECT_DUPLICATE_KEEP (3600 * 24)
/* Forward declarations */
static bool cmd_redirect_opcode_dump
......@@ -238,8 +243,31 @@ static bool act_redirect_commit
const struct sieve_action_exec_env *aenv, void *tr_context, bool *keep)
{
struct act_redirect_context *ctx = (struct act_redirect_context *) tr_context;
const struct sieve_message_data *msgdata = aenv->msgdata;
const struct sieve_mail_environment *mailenv = aenv->mailenv;
const char *dupeid;
/* Prevent mail loops if possible */
dupeid = msgdata->id == NULL ?
NULL : t_strdup_printf("%s-%s", msgdata->id, ctx->to_address);
if (dupeid != NULL) {
/* Check whether we've seen this message before */
if (mailenv->duplicate_check(dupeid, strlen(dupeid), mailenv->username)) {
sieve_result_log(aenv, "discarded duplicate forward to <%s>",
str_sanitize(ctx->to_address, 80));
return TRUE;
}
}
/* Try to forward the message */
if ( act_redirect_send(aenv, ctx) ) {
/* Mark this message id as forwarded to the specified destination */
if (dupeid != NULL) {
mailenv->duplicate_mark(dupeid, strlen(dupeid), mailenv->username,
ioloop_time + CMD_REDIRECT_DUPLICATE_KEEP);
}
sieve_result_log(aenv, "forwarded to <%s>",
str_sanitize(ctx->to_address, 80));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.