We were able to solve the problem, "When a control character is included in the subject of an e-mail, dovecot exits with a fatal error" using the following information: 1. We added the following field to the sieve setting file: /etc/dovecot/conf.d/90-sieve.conf --------------------------------------------------------------------- sieve_editheader_rfc2822_check = yes --------------------------------------------------------------------- This is a switch for whether or not to check if a file is RFC2822 or not. When it's set to yes, it works the exact same as before changes were made. The default is yes. 2. When the sieve_editheader_rfc2822_check setting is set to no, we make sure not to check for RFC2822. Version: dovecot-2.2-pigeonhole-0.4.2 The patch is listed as below: --------------------------------------------------------------------- diff -Nur dovecot-2.2-pigeonhole-0.4.2_org/src/lib-sieve/plugins/editheader/cmd-addheader.c dovecot-2.2-pigeonhole-0.4.2/src/lib-sieve/plugins/editheader/cmd-addheader.c --- dovecot-2.2-pigeonhole-0.4.2_org/src/lib-sieve/plugins/editheader/cmd-addheader.c 2014-05-14 15:17:52.586774630 +0900 +++ dovecot-2.2-pigeonhole-0.4.2/src/lib-sieve/plugins/editheader/cmd-addheader.c 2014-05-14 15:22:12.536780572 +0900 @@ -281,7 +281,8 @@ return SIEVE_EXEC_OK; } - if ( !rfc2822_header_field_body_verify + if ( this_ext->svinst->chk_rfc2822 == TRUE && + !rfc2822_header_field_body_verify (str_c(value), str_len(value), TRUE, TRUE) ) { sieve_runtime_error(renv, NULL, "addheader action: " "specified value `%s' is invalid", diff -Nur dovecot-2.2-pigeonhole-0.4.2_org/src/lib-sieve/sieve-common.h dovecot-2.2-pigeonhole-0.4.2/src/lib-sieve/sieve-common.h --- dovecot-2.2-pigeonhole-0.4.2_org/src/lib-sieve/sieve-common.h 2014-05-14 15:17:52.593774606 +0900 +++ dovecot-2.2-pigeonhole-0.4.2/src/lib-sieve/sieve-common.h 2014-05-14 15:23:57.584775286 +0900 @@ -189,6 +189,9 @@ size_t max_script_size; unsigned int max_actions; unsigned int max_redirects; + + /* Check */ + bool chk_rfc2822; }; #endif /* __SIEVE_COMMON_H */ diff -Nur dovecot-2.2-pigeonhole-0.4.2_org/src/lib-sieve/sieve.c dovecot-2.2-pigeonhole-0.4.2/src/lib-sieve/sieve.c --- dovecot-2.2-pigeonhole-0.4.2_org/src/lib-sieve/sieve.c 2014-05-14 15:17:52.583774672 +0900 +++ dovecot-2.2-pigeonhole-0.4.2/src/lib-sieve/sieve.c 2014-05-14 15:19:39.628771207 +0900 @@ -51,6 +51,7 @@ size_t size_setting; const char *domain; pool_t pool; + bool bool_setting; /* Create Sieve engine instance */ pool = pool_alloconly_create("sieve", 8192); @@ -118,6 +119,15 @@ svinst->max_redirects = (unsigned int) uint_setting; } + /* Check RFC2822 from configuration */ + + svinst->chk_rfc2822 = TRUE; + + if (sieve_setting_get_bool_value + (svinst, "sieve_editheader_rfc2822_check", &bool_setting) ) { + svinst->chk_rfc2822 = bool_setting; + } + /* Initialize extensions */ if ( !sieve_extensions_init(svinst) ) { sieve_deinit(&svinst); ---------------------------------------------------------------------
1) When an e-mail's subject contains control characters like [Ctrl+V|^V], dovecot.sieve terminates with an error and an e-mail is not able to be sent. When a MIME encoded Subject like [TEST^VMAIL] is sent we're not able to edit the subject and dovecot ends with an error.
This is a sample of the data that was used in testing. Subject: =?ISO-2022-JP?B?GyRCI1QjRSNTI1QbKEIWGyRCI00jQSNJI0wbKEI=?= X-Spam-Score: 100.00% ↓ Subject: =?ISO-2022-JP?B?GyRCI1QjRSNTI1QbKEIWGyRCI00jQSNJI0wbKEI=?= X-Spam-Score: 100.00%
This is the log generated by the data above. ---------------------------------------------------------------------- sieve: info: started log at May 02 10:46:22. main script: line 14: error: addheader action: specified value `[SPAM] TEST?・・' is invalid. ----------------------------------------------------------------------
Aside from [Ctrl + V] the following control charcters also cause errors: backspace Ctrl + A Ctrl + C Ctrl + [ Ctrl + X Ctrl + Y
Atsuko Tanaka