dovecot-2.2-pigeonhole: lib-sieve: util: edit-mail: Fixed a few ...
pigeonhole at rename-it.nl
pigeonhole at rename-it.nl
Thu Jul 31 00:17:57 UTC 2014
details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/2db02e11cd5e
changeset: 1904:2db02e11cd5e
user: Stephan Bosch <stephan at rename-it.nl>
date: Thu Jul 31 02:17:50 2014 +0200
description:
lib-sieve: util: edit-mail: Fixed a few bugs in previous commit.
diffstat:
src/lib-sieve/util/edit-mail.c | 46 ++++++++++++++++++++++++++++++++++++++---
1 files changed, 42 insertions(+), 4 deletions(-)
diffs (103 lines):
diff -r b68ddffa0ac1 -r 2db02e11cd5e src/lib-sieve/util/edit-mail.c
--- a/src/lib-sieve/util/edit-mail.c Thu Jul 31 01:37:22 2014 +0200
+++ b/src/lib-sieve/util/edit-mail.c Thu Jul 31 02:17:50 2014 +0200
@@ -611,7 +611,8 @@
i_free(field_idx);
}
-static void edit_mail_header_field_replace
+static struct _header_field_index *
+edit_mail_header_field_replace
(struct edit_mail *edmail, struct _header_field_index *field_idx,
const char *newname, const char *newvalue, bool update_index)
{
@@ -684,11 +685,31 @@
i_assert( hfield != NULL );
header_idx->last = hfield;
}
+ if ( header_idx_new->count > 0 ) {
+ struct _header_field_index *hfield;
+
+ hfield = edmail->header_fields_head;
+ while ( hfield != NULL && hfield->header != header_idx_new ) {
+ hfield = hfield->next;
+ }
+
+ i_assert( hfield != NULL );
+ header_idx_new->first = hfield;
+
+ hfield = edmail->header_fields_tail;
+ while ( hfield != NULL && hfield->header != header_idx_new ) {
+ hfield = hfield->prev;
+ }
+
+ i_assert( hfield != NULL );
+ header_idx_new->last = hfield;
+ }
}
}
_header_field_unref(field_idx->field);
i_free(field_idx);
+ return field_idx_new;
}
static inline char *_header_decode
@@ -992,8 +1013,8 @@
(struct edit_mail *edmail, const char *field_name, int index,
const char *newname, const char *newvalue)
{
- struct _header_index *header_idx;
- struct _header_field_index *field_idx;
+ struct _header_index *header_idx, *header_idx_new;
+ struct _header_field_index *field_idx, *field_idx_new;
int pos = 0;
int ret = 0;
@@ -1012,6 +1033,7 @@
/* Iterate through all header fields and replace those that match */
field_idx = ( index >= 0 ? header_idx->first : header_idx->last );
+ field_idx_new = NULL;
while ( field_idx != NULL ) {
struct _header_field_index *next =
( index >= 0 ? field_idx->next : field_idx->prev );
@@ -1030,7 +1052,7 @@
if ( index == 0 || index == pos ) {
if ( header_idx->first == field_idx ) header_idx->first = NULL;
if ( header_idx->last == field_idx ) header_idx->last = NULL;
- edit_mail_header_field_replace
+ field_idx_new = edit_mail_header_field_replace
(edmail, field_idx, newname, newvalue, FALSE);
ret++;
}
@@ -1042,6 +1064,7 @@
field_idx = next;
}
+ /* Update old header index */
if ( header_idx->count == 0 ) {
DLLIST2_REMOVE(&edmail->headers_head, &edmail->headers_tail, header_idx);
_header_unref(header_idx->header);
@@ -1059,6 +1082,21 @@
}
}
+ /* Update new header index */
+ if ( field_idx_new != NULL ) {
+ struct _header_field_index *current = edmail->header_fields_head;
+
+ header_idx_new = field_idx_new->header;
+ while ( current != NULL ) {
+ if ( current->header == header_idx_new ) {
+ if ( header_idx_new->first == NULL )
+ header_idx_new->first = current;
+ header_idx_new->last = current;
+ }
+ current = current->next;
+ }
+ }
+
return ret;
}
More information about the dovecot-cvs
mailing list