diff --git a/src/lib-sieve/plugins/vacation/cmd-vacation.c b/src/lib-sieve/plugins/vacation/cmd-vacation.c index 6a6a468310c12676ae03145d5db5c9cb5d1b294c..191b8ece101238d440d4eaa7386d89d64253aeb9 100644 --- a/src/lib-sieve/plugins/vacation/cmd-vacation.c +++ b/src/lib-sieve/plugins/vacation/cmd-vacation.c @@ -207,6 +207,7 @@ struct act_vacation_context { const char *handle; bool mime; const char *from; + const char *from_normalized; const char *const *addresses; }; @@ -551,6 +552,7 @@ static int ext_vacation_operation_execute struct sieve_coded_stringlist *addresses = NULL; string_t *reason, *subject = NULL, *from = NULL, *handle = NULL; unsigned int source_line; + const char *from_normalized = NULL; /* * Read operands @@ -635,6 +637,20 @@ static int ext_vacation_operation_execute sieve_runtime_trace(renv, "VACATION action"); + /* Check and normalize :from address */ + if ( from != NULL ) { + const char *error; + + from_normalized = sieve_address_normalize(from, &error); + + if ( from_normalized == NULL) { + sieve_runtime_error(renv, + sieve_error_script_location(renv->script, source_line), + "specified :from address '%s' is invalid for vacation action: %s", + str_sanitize(str_c(from), 128), error); + } + } + /* Add vacation action to the result */ pool = sieve_result_pool(renv->result); @@ -645,8 +661,11 @@ static int ext_vacation_operation_execute act->mime = mime; if ( subject != NULL ) act->subject = p_strdup(pool, str_c(subject)); - if ( from != NULL ) + if ( from != NULL ) { act->from = p_strdup(pool, str_c(from)); + act->from_normalized = p_strdup(pool, from_normalized); + } + if ( addresses != NULL ) sieve_coded_stringlist_read_all(addresses, pool, &(act->addresses)); @@ -816,15 +835,21 @@ static bool act_vacation_send outmsgid = sieve_get_new_message_id(senv); /* Produce a proper reply */ - + + rfc2822_header_field_write(f, "X-Sieve", SIEVE_IMPLEMENTATION); rfc2822_header_field_write(f, "Message-ID", outmsgid); rfc2822_header_field_write(f, "Date", message_date_create(ioloop_time)); + if ( ctx->from != NULL && *(ctx->from) != '\0' ) - rfc2822_header_field_printf(f, "From", "<%s>", ctx->from); + rfc2822_header_field_printf(f, "From", "%s", ctx->from); else rfc2822_header_field_printf(f, "From", "<%s>", msgdata->to_address); + /* FIXME: If From header of message has same address, we should use that in + * stead properly include the phrase part. + */ rfc2822_header_field_printf(f, "To", "<%s>", msgdata->return_path); + rfc2822_header_field_printf(f, "Subject", "%s", str_sanitize(ctx->subject, 256)); @@ -844,7 +869,6 @@ static bool act_vacation_send } rfc2822_header_field_write(f, "Auto-Submitted", "auto-replied (vacation)"); - rfc2822_header_field_write(f, "X-Sieve", SIEVE_IMPLEMENTATION); rfc2822_header_field_write(f, "Precedence", "bulk"); rfc2822_header_field_write(f, "MIME-Version", "1.0"); diff --git a/src/lib-sieve/sieve-address.c b/src/lib-sieve/sieve-address.c index ec962f806101fc91143ba4e30ca8653b52b51ad6..35593ae4f4fac5bbad8376eaaba3ba8eadbdc020 100644 --- a/src/lib-sieve/sieve-address.c +++ b/src/lib-sieve/sieve-address.c @@ -324,30 +324,7 @@ bool sieve_address_validate { struct sieve_message_address_parser ctx; - memset(&ctx, 0, sizeof(ctx));bool sieve_validate_rfc2822_mailbox(const char *address, const char **error_r) -{ - struct sieve_message_address_parser ctx; - memset(&ctx, 0, sizeof(ctx)); - - ctx.local_part = t_str_new(128); - ctx.domain = t_str_new(128); - ctx.str = t_str_new(128); - ctx.error = t_str_new(128); - - if ( !parse_mailbox_address(&ctx, (const unsigned char *) address, - strlen(address)) ) { - if ( error_r != NULL ) - *error_r = str_c(ctx.error); - return FALSE; - } - - if ( error_r != NULL ) - *error_r = NULL; - - return TRUE; -} - ctx.local_part = ctx.domain = ctx.str = t_str_new(128); ctx.error = t_str_new(128);