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

lib-sieve: util: rfc2822: Added rfc2822_header_write_address() which allows...

lib-sieve: util: rfc2822: Added rfc2822_header_write_address() which allows adding a header with one or more addresses.

It applies UTF8 encoding only when the address string somehow contains 8-bit characters.
Sieve addresses are supposed to have any UTF8 characters in the phase MIME-encoded, not literal 8-bit characters.
However, this has been allowed from the beginning, so disabling the old behavior may break existing installations.
This function allows supporting both options.
parent fe3b7c4b
No related branches found
No related tags found
No related merge requests found
......@@ -242,3 +242,23 @@ void rfc2822_header_utf8_printf
rfc2822_header_write(header, name, str_c(body));
}
void rfc2822_header_write_address(string_t *header,
const char *name, const char *address)
{
bool has_8bit = FALSE;
const char *p;
for (p = address; *p != '\0'; p++) {
if ((*p & 0x80) != 0)
has_8bit = TRUE;
}
if (!has_8bit) {
rfc2822_header_write(header, name, address);
} else {
string_t *body = t_str_new(256);
message_header_encode(address, body);
rfc2822_header_write(header, name, str_c(body));
}
}
......@@ -42,4 +42,8 @@ void rfc2822_header_printf
void rfc2822_header_utf8_printf
(string_t *header, const char *name, const char *fmt, ...) ATTR_FORMAT(3, 4);
void rfc2822_header_write_address(string_t *header,
const char *name, const char *address);
#endif /* __RFC2822_H */
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.