Skip to content

Commit

Permalink
lib-sieve: vacation extension: Make codepoint limit for subject heade…
Browse files Browse the repository at this point in the history
…r configurable.
  • Loading branch information
stephanbosch authored and villesavolainen committed Apr 27, 2018
1 parent 57a69b2 commit bb98761
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions doc/extensions/vacation.txt
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/lib-sieve/plugins/vacation/cmd-vacation.c
Expand Up @@ -1006,7 +1006,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 */

Expand Down
7 changes: 7 additions & 0 deletions src/lib-sieve/plugins/vacation/ext-vacation-common.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/lib-sieve/plugins/vacation/ext-vacation-common.h
Expand Up @@ -13,11 +13,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;
Expand Down

0 comments on commit bb98761

Please sign in to comment.