From ffbcd3bfd367e2d22532c2c3244f38809623474e Mon Sep 17 00:00:00 2001 From: Stephan Bosch <stephan.bosch@dovecot.fi> Date: Mon, 16 Apr 2018 20:42:46 +0200 Subject: [PATCH] lib-sieve: vacation extension: Make codepoint limit for subject header configurable. --- doc/extensions/vacation.txt | 7 +++++++ src/lib-sieve/plugins/vacation/cmd-vacation.c | 2 +- src/lib-sieve/plugins/vacation/ext-vacation-common.c | 7 +++++++ src/lib-sieve/plugins/vacation/ext-vacation-common.h | 2 ++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/doc/extensions/vacation.txt b/doc/extensions/vacation.txt index 9b9856f72..3e405a9d1 100644 --- a/doc/extensions/vacation.txt +++ b/doc/extensions/vacation.txt @@ -53,6 +53,13 @@ sieve_vacation_default_period = 7d is specified. The configured value must lie between the sieve_vacation_min_period and sieve_vacation_max_period. +sieve_vacation_max_subject_codepoints = 256 + The maximum number of Unicode codepoints used in the Subject header generated + for the outgoing vacation message. When composite characters are involved, + the number of actual charactes in the Subject text can be less than this + number, otherwise it is equal. When the subject text exceeds the limit, it is + truncated and the removed part is replaced with an ellipsis character ('...'). + sieve_vacation_use_original_recipient = no This specifies whether the original envelope recipient should be used in the check for implicit delivery. The vacation command checks headers of the diff --git a/src/lib-sieve/plugins/vacation/cmd-vacation.c b/src/lib-sieve/plugins/vacation/cmd-vacation.c index 507941cfa..b09e7a1b2 100644 --- a/src/lib-sieve/plugins/vacation/cmd-vacation.c +++ b/src/lib-sieve/plugins/vacation/cmd-vacation.c @@ -990,7 +990,7 @@ static int act_vacation_send subject = ctx->subject; } - subject = str_sanitize_utf8(subject, 256); + subject = str_sanitize_utf8(subject, config->max_subject_codepoints); /* Obtain full To address for reply */ diff --git a/src/lib-sieve/plugins/vacation/ext-vacation-common.c b/src/lib-sieve/plugins/vacation/ext-vacation-common.c index bb3814069..67c2513bf 100644 --- a/src/lib-sieve/plugins/vacation/ext-vacation-common.c +++ b/src/lib-sieve/plugins/vacation/ext-vacation-common.c @@ -18,6 +18,7 @@ bool ext_vacation_load sieve_number_t min_period, max_period, default_period; bool use_original_recipient, dont_check_recipient, send_from_recipient, to_header_ignore_envelope; + unsigned long long max_subject_codepoints; if ( *context != NULL ) { ext_vacation_unload(ext); @@ -51,6 +52,11 @@ bool ext_vacation_load "sieve_vacation_max_period"); } + if ( !sieve_setting_get_uint_value + (svinst, "sieve_vacation_max_subject_codepoints", &max_subject_codepoints) ) { + max_subject_codepoints = EXT_VACATION_DEFAULT_MAX_SUBJECT_CODEPOINTS; + } + if ( !sieve_setting_get_bool_value (svinst, "sieve_vacation_use_original_recipient", &use_original_recipient) ) { use_original_recipient = FALSE; @@ -76,6 +82,7 @@ bool ext_vacation_load config->min_period = min_period; config->max_period = max_period; config->default_period = default_period; + config->max_subject_codepoints = max_subject_codepoints; config->use_original_recipient = use_original_recipient; config->dont_check_recipient = dont_check_recipient; config->send_from_recipient = send_from_recipient; diff --git a/src/lib-sieve/plugins/vacation/ext-vacation-common.h b/src/lib-sieve/plugins/vacation/ext-vacation-common.h index f93b6e2a2..e82c40c42 100644 --- a/src/lib-sieve/plugins/vacation/ext-vacation-common.h +++ b/src/lib-sieve/plugins/vacation/ext-vacation-common.h @@ -10,11 +10,13 @@ #define EXT_VACATION_DEFAULT_PERIOD (7*24*60*60) #define EXT_VACATION_DEFAULT_MIN_PERIOD (24*60*60) #define EXT_VACATION_DEFAULT_MAX_PERIOD 0 +#define EXT_VACATION_DEFAULT_MAX_SUBJECT_CODEPOINTS 256 struct ext_vacation_config { unsigned int min_period; unsigned int max_period; unsigned int default_period; + unsigned long long max_subject_codepoints; bool use_original_recipient; bool dont_check_recipient; bool send_from_recipient; -- GitLab