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

Vacation: properly implemented use of :from address argument.

parent 63ed66d9
No related branches found
No related tags found
No related merge requests found
...@@ -207,6 +207,7 @@ struct act_vacation_context { ...@@ -207,6 +207,7 @@ struct act_vacation_context {
const char *handle; const char *handle;
bool mime; bool mime;
const char *from; const char *from;
const char *from_normalized;
const char *const *addresses; const char *const *addresses;
}; };
...@@ -551,6 +552,7 @@ static int ext_vacation_operation_execute ...@@ -551,6 +552,7 @@ static int ext_vacation_operation_execute
struct sieve_coded_stringlist *addresses = NULL; struct sieve_coded_stringlist *addresses = NULL;
string_t *reason, *subject = NULL, *from = NULL, *handle = NULL; string_t *reason, *subject = NULL, *from = NULL, *handle = NULL;
unsigned int source_line; unsigned int source_line;
const char *from_normalized = NULL;
/* /*
* Read operands * Read operands
...@@ -635,6 +637,20 @@ static int ext_vacation_operation_execute ...@@ -635,6 +637,20 @@ static int ext_vacation_operation_execute
sieve_runtime_trace(renv, "VACATION action"); 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 */ /* Add vacation action to the result */
pool = sieve_result_pool(renv->result); pool = sieve_result_pool(renv->result);
...@@ -645,8 +661,11 @@ static int ext_vacation_operation_execute ...@@ -645,8 +661,11 @@ static int ext_vacation_operation_execute
act->mime = mime; act->mime = mime;
if ( subject != NULL ) if ( subject != NULL )
act->subject = p_strdup(pool, str_c(subject)); act->subject = p_strdup(pool, str_c(subject));
if ( from != NULL ) if ( from != NULL ) {
act->from = p_strdup(pool, str_c(from)); act->from = p_strdup(pool, str_c(from));
act->from_normalized = p_strdup(pool, from_normalized);
}
if ( addresses != NULL ) if ( addresses != NULL )
sieve_coded_stringlist_read_all(addresses, pool, &(act->addresses)); sieve_coded_stringlist_read_all(addresses, pool, &(act->addresses));
...@@ -819,12 +838,17 @@ static bool act_vacation_send ...@@ -819,12 +838,17 @@ static bool act_vacation_send
rfc2822_header_field_write(f, "Message-ID", outmsgid); rfc2822_header_field_write(f, "Message-ID", outmsgid);
rfc2822_header_field_write(f, "Date", message_date_create(ioloop_time)); 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); if ( ctx->from_normalized != NULL && *(ctx->from_normalized) != '\0' )
rfc2822_header_field_printf(f, "From", "%s", ctx->from_normalized);
else else
rfc2822_header_field_printf(f, "From", "<%s>", msgdata->to_address); 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, "To", "<%s>", msgdata->return_path);
rfc2822_header_field_printf(f, "Subject", "%s", rfc2822_header_field_printf(f, "Subject", "%s",
str_sanitize(ctx->subject, 256)); str_sanitize(ctx->subject, 256));
......
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.