From 4ae8961947f10a7fa7a4dd256fb7a09cf009ad2f Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Wed, 8 Mar 2017 08:42:56 -0500 Subject: [PATCH] (fix) handle when mail starts with Bcc header (fixes #4073) --- SoObjects/SOGo/SOGoMailer.m | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/SoObjects/SOGo/SOGoMailer.m b/SoObjects/SOGo/SOGoMailer.m index de9ef7008..2dbaa4d73 100644 --- a/SoObjects/SOGo/SOGoMailer.m +++ b/SoObjects/SOGo/SOGoMailer.m @@ -356,9 +356,17 @@ // we find \r\n\r\n, which is the headers delimiter r1 = [cleaned_message rangeOfCString: "\r\n\r\n"]; limit = r1.location-1; - r1 = [cleaned_message rangeOfCString: "\r\nBcc: " + + // We check if the mail actually *starts* with the Bcc: header + r1 = [cleaned_message rangeOfCString: "Bcc: " options: 0 - range: NSMakeRange(0,limit)]; + range: NSMakeRange(0,5)]; + + // It does not, let's search in the entire headers + if (r1.location == NSNotFound) + r1 = [cleaned_message rangeOfCString: "\r\nBcc: " + options: 0 + range: NSMakeRange(0,limit)]; if (r1.location != NSNotFound) { @@ -374,7 +382,7 @@ break; } - [cleaned_message replaceBytesInRange: NSMakeRange(r1.location, i-r1.location) + [cleaned_message replaceBytesInRange: NSMakeRange(r1.location, i-r1.location+2) withBytes: NULL length: 0]; }