dovecot-2.1-pigeonhole: lib-sieve: editheader extension: fixed h...
pigeonhole at rename-it.nl
pigeonhole at rename-it.nl
Sat Nov 26 15:19:57 EET 2011
details: http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/f7ec0ff8c3ba
changeset: 1558:f7ec0ff8c3ba
user: Stephan Bosch <stephan at rename-it.nl>
date: Sat Nov 26 14:19:09 2011 +0100
description:
lib-sieve: editheader extension: fixed handling of pre-folded header values for added header fields.
diffstat:
src/lib-sieve/edit-mail.c | 41 ++++++++++++++++++++++++++++++++++++++---
1 files changed, 38 insertions(+), 3 deletions(-)
diffs (65 lines):
diff -r 3d01485cb539 -r f7ec0ff8c3ba src/lib-sieve/edit-mail.c
--- a/src/lib-sieve/edit-mail.c Sat Nov 26 14:18:05 2011 +0100
+++ b/src/lib-sieve/edit-mail.c Sat Nov 26 14:19:09 2011 +0100
@@ -689,6 +689,43 @@
return 1;
}
+static inline char *_header_value_unfold
+(const char *value)
+{
+ string_t *out;
+ unsigned int i, j;
+
+ for (i = 0; value[i] != '\0'; i++) {
+ if (value[i] == '\r' || value[i] == '\n')
+ break;
+ }
+ if (value[i] == '\0') {
+ return i_strdup(value);
+ }
+
+ out = t_str_new(i + strlen(value+i) + 10);
+ str_append_n(out, value, i);
+ for (j = i; value[i] != '\0'; i++) {
+ if (value[i] == '\n') {
+ i++;
+ if (value[i] == '\0')
+ break;
+
+ switch ( value[i] ) {
+ default:
+ str_append_c(out, '\t');
+ case ' ': case '\t':
+ str_append_c(out, value[i]);
+ }
+ } else {
+ if (value[i] != '\r')
+ str_append_c(out, value[i]);
+ }
+ }
+
+ return i_strndup(str_c(out), str_len(out));
+}
+
void edit_mail_header_add
(struct edit_mail *edmail, const char *field_name, const char *value, bool last)
{
@@ -698,8 +735,6 @@
struct _header_field *field;
unsigned int lines;
- /* FIXME: validate value */
-
edit_mail_modify(edmail);
/* Get/create header index item */
@@ -731,7 +766,7 @@
} T_END;
/* Record original (utf8) value */
- field->utf8_value = i_strdup(value);
+ field->utf8_value = _header_value_unfold(value);
/* Add it to the header field index */
if ( last ) {
More information about the dovecot-cvs
mailing list