Corrected behaviour for boundary deletion
Signed-off-by: Tyrolyean <tyrolyean@tyrolyean.net>
This commit is contained in:
parent
5d78635506
commit
0aa030735f
1 changed files with 9 additions and 17 deletions
26
src/mail.c
26
src/mail.c
|
@ -98,11 +98,16 @@ int remove_mail(struct email_t* mail){
|
||||||
|
|
||||||
struct email_t* parent = mail->parent;
|
struct email_t* parent = mail->parent;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
|
struct email_t * followup = NULL;
|
||||||
for(size_t i = 0; i < parent->submes_cnt; i++){
|
for(size_t i = 0; i < parent->submes_cnt; i++){
|
||||||
|
|
||||||
if(parent->submes[i] == mail){
|
if(parent->submes[i] == mail){
|
||||||
/* Remove ourselfs from the parent */
|
/* Remove ourselfs from the parent */
|
||||||
found = true;
|
found = true;
|
||||||
|
if(i+1 < parent->submes_cnt){
|
||||||
|
followup = parent->submes[i+1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(found && (i+1 < parent->submes_cnt)){
|
if(found && (i+1 < parent->submes_cnt)){
|
||||||
|
@ -116,24 +121,11 @@ int remove_mail(struct email_t* mail){
|
||||||
}
|
}
|
||||||
|
|
||||||
parent->submes_cnt--;
|
parent->submes_cnt--;
|
||||||
|
char* end = NULL;
|
||||||
/* Find the boundary that should come after our content */
|
if(followup == NULL){
|
||||||
|
|
||||||
char* boundary = malloc(parent->boundary_len+1);
|
|
||||||
memset(boundary, 0, parent->boundary_len+1);
|
|
||||||
memcpy(boundary,parent->boundary, parent->boundary_len);
|
|
||||||
|
|
||||||
char * after_boundary =
|
|
||||||
strstr(mail->message+mail->message_length, boundary);
|
|
||||||
free(boundary);
|
|
||||||
if(after_boundary == NULL){
|
|
||||||
fprintf(stderr, "Unable to find boundary!\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
const char * end = get_next_line(after_boundary,
|
|
||||||
parent->message_length-(after_boundary - parent->message));
|
|
||||||
if(end == NULL){
|
|
||||||
end = parent->message + parent->message_length;
|
end = parent->message + parent->message_length;
|
||||||
|
}else{
|
||||||
|
end = followup->message - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t remove_len = mail->message - end;
|
size_t remove_len = mail->message - end;
|
||||||
|
|
Loading…
Reference in a new issue