mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-31 03:07:17 +00:00
Revert merge from inverse
https://github.com/Zentyal/sogo/pull/150 Because the login on web with the use of outlook is broken after including the DomainLessLogin feature
This commit is contained in:
@@ -66,33 +66,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
- (NSString *) activeSyncRepresentationInContext: (WOContext *) context
|
||||
{
|
||||
NSString *tmp, *s;
|
||||
unichar *buf, *start, c;
|
||||
int len, i, j;
|
||||
|
||||
tmp = [self stringByEncodingBase64] ;
|
||||
|
||||
len = [tmp length];
|
||||
|
||||
start = buf = (unichar *)malloc(len*sizeof(unichar));
|
||||
[tmp getCharacters: buf range: NSMakeRange(0, len)];
|
||||
|
||||
for (i = 0, j = 0; i < len; i++)
|
||||
{
|
||||
c = *buf;
|
||||
|
||||
if (!(c == 0xA))
|
||||
{
|
||||
*(start+j) = c;
|
||||
j++;
|
||||
}
|
||||
|
||||
buf++;
|
||||
}
|
||||
|
||||
s = [[NSString alloc] initWithCharactersNoCopy: start length: j freeWhenDone: YES];
|
||||
|
||||
return AUTORELEASE(s);
|
||||
return [[self stringByEncodingBase64] stringByReplacingString: @"\n" withString: @""];
|
||||
}
|
||||
|
||||
- (NSData *) wbxml2xml
|
||||
|
||||
@@ -46,99 +46,6 @@ static NSArray *easCommandParameters = nil;
|
||||
|
||||
@implementation NSString (ActiveSync)
|
||||
|
||||
//
|
||||
// This is a copy from NSString+XMLEscaping.m from SOPE.
|
||||
// The difference here is that we use wchar_t instead of unichar.
|
||||
// This is needed to get the rigth numeric character reference.
|
||||
// e.g. SMILING FACE WITH OPEN MOUTH
|
||||
// ok: wchar_t -> 😃 wrong: unichar -> � �
|
||||
//
|
||||
// We avoir naming it like the one in SOPE since if the ActiveSync
|
||||
// bundle is loaded, it'll overwrite the one provided by SOPE.
|
||||
//
|
||||
- (NSString *) _stringByEscapingXMLStringUsingCharacters {
|
||||
register unsigned i, len, j;
|
||||
register wchar_t *buf;
|
||||
const wchar_t *chars;
|
||||
unsigned escapeCount;
|
||||
|
||||
if ([self length] == 0) return @"";
|
||||
|
||||
NSData *data = [self dataUsingEncoding:NSUTF32StringEncoding];
|
||||
chars = [data bytes];
|
||||
len = [data length]/4;
|
||||
|
||||
/* check for characters to escape ... */
|
||||
for (i = 0, escapeCount = 0; i < len; i++) {
|
||||
switch (chars[i]) {
|
||||
case '&': case '"': case '<': case '>': case '\r':
|
||||
escapeCount++;
|
||||
break;
|
||||
default:
|
||||
if (chars[i] > 127)
|
||||
escapeCount++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (escapeCount == 0 ) {
|
||||
/* nothing to escape ... */
|
||||
return [[self copy] autorelease];
|
||||
}
|
||||
|
||||
buf = calloc((len + 5) + (escapeCount * 16), sizeof(wchar_t));
|
||||
for (i = 0, j = 0; i < len; i++) {
|
||||
switch (chars[i]) {
|
||||
/* escape special chars */
|
||||
case '\r':
|
||||
buf[j] = '&'; j++; buf[j] = '#'; j++; buf[j] = '1'; j++;
|
||||
buf[j] = '3'; j++; buf[j] = ';'; j++;
|
||||
break;
|
||||
case '&':
|
||||
buf[j] = '&'; j++; buf[j] = 'a'; j++; buf[j] = 'm'; j++;
|
||||
buf[j] = 'p'; j++; buf[j] = ';'; j++;
|
||||
break;
|
||||
case '"':
|
||||
buf[j] = '&'; j++; buf[j] = 'q'; j++; buf[j] = 'u'; j++;
|
||||
buf[j] = 'o'; j++; buf[j] = 't'; j++; buf[j] = ';'; j++;
|
||||
break;
|
||||
case '<':
|
||||
buf[j] = '&'; j++; buf[j] = 'l'; j++; buf[j] = 't'; j++;
|
||||
buf[j] = ';'; j++;
|
||||
break;
|
||||
case '>':
|
||||
buf[j] = '&'; j++; buf[j] = 'g'; j++; buf[j] = 't'; j++;
|
||||
buf[j] = ';'; j++;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* escape big chars */
|
||||
if (chars[i] > 127) {
|
||||
unsigned char nbuf[32];
|
||||
unsigned int k;
|
||||
|
||||
sprintf((char *)nbuf, "&#%i;", (int)chars[i]);
|
||||
for (k = 0; nbuf[k] != '\0'; k++) {
|
||||
buf[j] = nbuf[k];
|
||||
j++;
|
||||
}
|
||||
}
|
||||
else if (chars[i] == 0x9 || chars[i] == 0xA || chars[i] == 0xD || chars[i] >= 0x20) { // ignore any unsupported control character
|
||||
/* nothing to escape */
|
||||
buf[j] = chars[i];
|
||||
j++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
self = [[NSString alloc] initWithBytesNoCopy: buf
|
||||
length: (j*sizeof(wchar_t))
|
||||
encoding: NSUTF32StringEncoding
|
||||
freeWhenDone: YES];
|
||||
|
||||
return [self autorelease];
|
||||
}
|
||||
|
||||
- (NSString *) sanitizedServerIdWithType: (SOGoMicrosoftActiveSyncFolderType) folderType
|
||||
{
|
||||
if (folderType == ActiveSyncEventFolder)
|
||||
@@ -158,7 +65,11 @@ static NSArray *easCommandParameters = nil;
|
||||
|
||||
- (NSString *) activeSyncRepresentationInContext: (WOContext *) context
|
||||
{
|
||||
return [self _stringByEscapingXMLStringUsingCharacters];
|
||||
NSString *s;
|
||||
|
||||
s = [self safeString];
|
||||
|
||||
return [s stringByEscapingHTMLString];
|
||||
}
|
||||
|
||||
- (int) activeSyncFolderType
|
||||
|
||||
@@ -453,27 +453,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
withType: (SOGoMicrosoftActiveSyncFolderType) theFolderType
|
||||
inBuffer: (NSMutableString *) theBuffer
|
||||
{
|
||||
|
||||
id aDelete, sogoObject, value;
|
||||
NSArray *deletions;
|
||||
NSString *serverId;
|
||||
|
||||
BOOL deletesAsMoves, useTrash;
|
||||
id aDelete, sogoObject;
|
||||
int i;
|
||||
|
||||
deletions = (id)[theDocumentElement getElementsByTagName: @"Delete"];
|
||||
|
||||
if ([deletions count])
|
||||
{
|
||||
// From the documention, if DeletesAsMoves is missing, we must assume it's a YES.
|
||||
// See https://msdn.microsoft.com/en-us/library/gg675480(v=exchg.80).aspx for all details.
|
||||
value = [theDocumentElement getElementsByTagName: @"DeletesAsMoves"];
|
||||
deletesAsMoves = YES;
|
||||
useTrash = YES;
|
||||
|
||||
if ([value count] && [[[value lastObject] textValue] length])
|
||||
deletesAsMoves = [[[value lastObject] textValue] boolValue];
|
||||
|
||||
for (i = 0; i < [deletions count]; i++)
|
||||
{
|
||||
aDelete = [deletions objectAtIndex: i];
|
||||
@@ -485,13 +474,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
acquire: NO];
|
||||
|
||||
if (![sogoObject isKindOfClass: [NSException class]])
|
||||
{
|
||||
// FIXME: handle errors here
|
||||
if (deletesAsMoves)
|
||||
[(SOGoMailFolder *)[sogoObject container] deleteUIDs: [NSArray arrayWithObjects: serverId, nil] useTrashFolder: &useTrash inContext: context];
|
||||
else
|
||||
[sogoObject delete];
|
||||
}
|
||||
[sogoObject delete];
|
||||
|
||||
[theBuffer appendString: @"<Delete>"];
|
||||
[theBuffer appendFormat: @"<ServerId>%@</ServerId>", serverId];
|
||||
|
||||
@@ -453,7 +453,7 @@ static BOOL debugOn = NO;
|
||||
[s appendString: @"<FolderCreate xmlns=\"FolderHierarchy:\">"];
|
||||
[s appendFormat: @"<Status>%d</Status>", 1];
|
||||
[s appendFormat: @"<SyncKey>%@</SyncKey>", syncKey];
|
||||
[s appendFormat: @"<ServerId>%@</ServerId>", [nameInContainer stringByEscapingURL]];
|
||||
[s appendFormat: @"<ServerId>%@</ServerId>", nameInContainer];
|
||||
[s appendString: @"</FolderCreate>"];
|
||||
|
||||
d = [[s dataUsingEncoding: NSUTF8StringEncoding] xml2wbxml];
|
||||
@@ -1084,8 +1084,6 @@ static BOOL debugOn = NO;
|
||||
SOGoMailAccounts *accountsFolder;
|
||||
SOGoUserFolder *userFolder;
|
||||
SOGoMailObject *mailObject;
|
||||
NSArray *partKeys;
|
||||
int p;
|
||||
|
||||
NSRange r1, r2;
|
||||
|
||||
@@ -1105,14 +1103,7 @@ static BOOL debugOn = NO;
|
||||
acquire: NO];
|
||||
|
||||
mailObject = [currentCollection lookupName: messageName inContext: context acquire: NO];
|
||||
|
||||
partKeys = [pathToPart componentsSeparatedByString: @"."];
|
||||
|
||||
currentBodyPart = [mailObject lookupImap4BodyPartKey: [partKeys objectAtIndex:0] inContext: context];
|
||||
for (p = 1; p < [partKeys count]; p++)
|
||||
{
|
||||
currentBodyPart = [currentBodyPart lookupImap4BodyPartKey: [partKeys objectAtIndex:p] inContext: context];
|
||||
}
|
||||
currentBodyPart = [mailObject lookupImap4BodyPartKey: pathToPart inContext: context];
|
||||
|
||||
[theResponse setHeader: [NSString stringWithFormat: @"%@/%@", [[currentBodyPart partInfo] objectForKey: @"type"], [[currentBodyPart partInfo] objectForKey: @"subtype"]]
|
||||
forKey: @"Content-Type"];
|
||||
@@ -1167,11 +1158,11 @@ static BOOL debugOn = NO;
|
||||
{
|
||||
collectionId = [[(id)[[allCollections objectAtIndex: j] getElementsByTagName: @"CollectionId"] lastObject] textValue];
|
||||
realCollectionId = [collectionId realCollectionIdWithFolderType: &folderType];
|
||||
|
||||
|
||||
if (folderType == ActiveSyncMailFolder)
|
||||
nameInCache = [NSString stringWithFormat: @"folder%@", realCollectionId];
|
||||
nameInCache = [NSString stringWithFormat: @"folder%@", realCollectionId];
|
||||
else
|
||||
nameInCache = collectionId;
|
||||
nameInCache = collectionId;
|
||||
|
||||
realCollectionId = [self globallyUniqueIDToIMAPFolderName: realCollectionId type: folderType];
|
||||
|
||||
@@ -1243,11 +1234,10 @@ static BOOL debugOn = NO;
|
||||
- (void) processItemOperations: (id <DOMElement>) theDocumentElement
|
||||
inResponse: (WOResponse *) theResponse
|
||||
{
|
||||
NSString *fileReference, *realCollectionId, *serverId, *bodyPreferenceType, *collectionId;
|
||||
NSString *fileReference, *realCollectionId;
|
||||
NSMutableString *s;
|
||||
NSArray *fetchRequests;
|
||||
id aFetch;
|
||||
NSData *d;
|
||||
int i;
|
||||
|
||||
SOGoMicrosoftActiveSyncFolderType folderType;
|
||||
@@ -1257,6 +1247,8 @@ static BOOL debugOn = NO;
|
||||
[s appendString: @"<?xml version=\"1.0\" encoding=\"utf-8\"?>"];
|
||||
[s appendString: @"<!DOCTYPE ActiveSync PUBLIC \"-//MICROSOFT//DTD ActiveSync//EN\" \"http://www.microsoft.com/\">"];
|
||||
[s appendString: @"<ItemOperations xmlns=\"ItemOperations:\">"];
|
||||
[s appendString: @"<Status>1</Status>"];
|
||||
[s appendString: @"<Response>"];
|
||||
|
||||
fetchRequests = (id)[theDocumentElement getElementsByTagName: @"Fetch"];
|
||||
|
||||
@@ -1264,25 +1256,17 @@ static BOOL debugOn = NO;
|
||||
{
|
||||
NSMutableData *bytes, *parts;
|
||||
NSMutableArray *partLength;
|
||||
NSData *d;
|
||||
|
||||
bytes = [NSMutableData data];
|
||||
parts = [NSMutableData data];
|
||||
partLength = [NSMutableArray array];
|
||||
|
||||
[s appendString: @"<Status>1</Status>"];
|
||||
[s appendString: @"<Response>"];
|
||||
|
||||
for (i = 0; i < [fetchRequests count]; i++)
|
||||
{
|
||||
aFetch = [fetchRequests objectAtIndex: i];
|
||||
fileReference = [[[(id)[aFetch getElementsByTagName: @"FileReference"] lastObject] textValue] stringByUnescapingURL];
|
||||
collectionId = [[(id)[theDocumentElement getElementsByTagName: @"CollectionId"] lastObject] textValue];
|
||||
|
||||
// its either a itemOperation to fetch an attachment or an email
|
||||
if ([fileReference length])
|
||||
realCollectionId = [fileReference realCollectionIdWithFolderType: &folderType];
|
||||
else
|
||||
realCollectionId = [collectionId realCollectionIdWithFolderType: &folderType];
|
||||
realCollectionId = [fileReference realCollectionIdWithFolderType: &folderType];
|
||||
|
||||
if (folderType == ActiveSyncMailFolder)
|
||||
{
|
||||
@@ -1292,80 +1276,43 @@ static BOOL debugOn = NO;
|
||||
SOGoUserFolder *userFolder;
|
||||
SOGoMailObject *mailObject;
|
||||
|
||||
if ([fileReference length])
|
||||
{
|
||||
// fetch attachment
|
||||
NSRange r1, r2;
|
||||
NSArray *partKeys;
|
||||
int p;
|
||||
NSRange r1, r2;
|
||||
|
||||
r1 = [realCollectionId rangeOfString: @"/"];
|
||||
r2 = [realCollectionId rangeOfString: @"/" options: 0 range: NSMakeRange(NSMaxRange(r1)+1, [realCollectionId length]-NSMaxRange(r1)-1)];
|
||||
r1 = [realCollectionId rangeOfString: @"/"];
|
||||
r2 = [realCollectionId rangeOfString: @"/" options: 0 range: NSMakeRange(NSMaxRange(r1)+1, [realCollectionId length]-NSMaxRange(r1)-1)];
|
||||
|
||||
folderName = [realCollectionId substringToIndex: r1.location];
|
||||
messageName = [realCollectionId substringWithRange: NSMakeRange(NSMaxRange(r1), r2.location-r1.location-1)];
|
||||
pathToPart = [realCollectionId substringFromIndex: r2.location+1];
|
||||
folderName = [realCollectionId substringToIndex: r1.location];
|
||||
messageName = [realCollectionId substringWithRange: NSMakeRange(NSMaxRange(r1), r2.location-r1.location-1)];
|
||||
pathToPart = [realCollectionId substringFromIndex: r2.location+1];
|
||||
|
||||
userFolder = [[context activeUser] homeFolderInContext: context];
|
||||
accountsFolder = [userFolder lookupName: @"Mail" inContext: context acquire: NO];
|
||||
currentFolder = [accountsFolder lookupName: @"0" inContext: context acquire: NO];
|
||||
userFolder = [[context activeUser] homeFolderInContext: context];
|
||||
accountsFolder = [userFolder lookupName: @"Mail" inContext: context acquire: NO];
|
||||
currentFolder = [accountsFolder lookupName: @"0" inContext: context acquire: NO];
|
||||
|
||||
currentCollection = [currentFolder lookupName: [NSString stringWithFormat: @"folder%@", folderName]
|
||||
inContext: context
|
||||
acquire: NO];
|
||||
currentCollection = [currentFolder lookupName: [NSString stringWithFormat: @"folder%@", folderName]
|
||||
inContext: context
|
||||
acquire: NO];
|
||||
|
||||
mailObject = [currentCollection lookupName: messageName inContext: context acquire: NO];
|
||||
mailObject = [currentCollection lookupName: messageName inContext: context acquire: NO];
|
||||
currentBodyPart = [mailObject lookupImap4BodyPartKey: pathToPart inContext: context];
|
||||
|
||||
partKeys = [pathToPart componentsSeparatedByString: @"."];
|
||||
[s appendString: @"<Fetch>"];
|
||||
[s appendString: @"<Status>1</Status>"];
|
||||
[s appendFormat: @"<FileReference xmlns=\"AirSyncBase:\">%@</FileReference>", [fileReference stringByEscapingURL]];
|
||||
[s appendString: @"<Properties>"];
|
||||
|
||||
currentBodyPart = [mailObject lookupImap4BodyPartKey: [partKeys objectAtIndex:0] inContext: context];
|
||||
for (p = 1; p < [partKeys count]; p++)
|
||||
{
|
||||
currentBodyPart = [currentBodyPart lookupImap4BodyPartKey: [partKeys objectAtIndex:p] inContext: context];
|
||||
}
|
||||
|
||||
[s appendString: @"<Fetch>"];
|
||||
[s appendString: @"<Status>1</Status>"];
|
||||
[s appendFormat: @"<FileReference xmlns=\"AirSyncBase:\">%@</FileReference>", [fileReference stringByEscapingURL]];
|
||||
[s appendString: @"<Properties>"];
|
||||
[s appendFormat: @"<ContentType xmlns=\"AirSyncBase:\">%@/%@</ContentType>", [[currentBodyPart partInfo] objectForKey: @"type"], [[currentBodyPart partInfo] objectForKey: @"subtype"]];
|
||||
|
||||
[s appendFormat: @"<ContentType xmlns=\"AirSyncBase:\">%@/%@</ContentType>", [[currentBodyPart partInfo] objectForKey: @"type"], [[currentBodyPart partInfo] objectForKey: @"subtype"]];
|
||||
|
||||
if ([[theResponse headerForKey: @"Content-Type"] isEqualToString:@"application/vnd.ms-sync.multipart"])
|
||||
{
|
||||
NSData *d;
|
||||
d = [currentBodyPart fetchBLOB];
|
||||
|
||||
[s appendFormat: @"<Part>%d</Part>", i+1];
|
||||
[partLength addObject: [NSNumber numberWithInteger: [d length]]];
|
||||
[parts appendData: d];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString *a;
|
||||
a = [[currentBodyPart fetchBLOB] activeSyncRepresentationInContext: context];
|
||||
|
||||
[s appendFormat: @"<Range>0-%d</Range>", [a length]-1];
|
||||
[s appendFormat: @"<Data>%@</Data>", a];
|
||||
}
|
||||
if ([[theResponse headerForKey: @"Content-Type"] isEqualToString:@"application/vnd.ms-sync.multipart"])
|
||||
{
|
||||
[s appendFormat: @"<Part>%d</Part>", i+1];
|
||||
[partLength addObject: [NSNumber numberWithInteger: [[currentBodyPart fetchBLOB] length]]];
|
||||
[parts appendData:[currentBodyPart fetchBLOB]];
|
||||
}
|
||||
else
|
||||
{
|
||||
// fetch mail
|
||||
realCollectionId = [self globallyUniqueIDToIMAPFolderName: realCollectionId type: folderType];
|
||||
serverId = [[(id)[theDocumentElement getElementsByTagName: @"ServerId"] lastObject] textValue];
|
||||
bodyPreferenceType = [[(id)[[(id)[theDocumentElement getElementsByTagName: @"BodyPreference"] lastObject] getElementsByTagName: @"Type"] lastObject] textValue];
|
||||
[context setObject: bodyPreferenceType forKey: @"BodyPreferenceType"];
|
||||
|
||||
currentCollection = [self collectionFromId: realCollectionId type: folderType];
|
||||
|
||||
mailObject = [currentCollection lookupName: serverId inContext: context acquire: NO];
|
||||
[s appendString: @"<Fetch>"];
|
||||
[s appendString: @"<Status>1</Status>"];
|
||||
[s appendFormat: @"<CollectionId xmlns=\"AirSyncBase:\">%@</CollectionId>", collectionId];
|
||||
[s appendFormat: @"<ServerId xmlns=\"AirSyncBase:\">%@</ServerId>", serverId];
|
||||
[s appendString: @"<Properties>"];
|
||||
[s appendString: [mailObject activeSyncRepresentationInContext: context]];
|
||||
[s appendFormat: @"<Range>0-%d</Range>", [[[currentBodyPart fetchBLOB] activeSyncRepresentationInContext: context] length]-1];
|
||||
[s appendFormat: @"<Data>%@</Data>", [[currentBodyPart fetchBLOB] activeSyncRepresentationInContext: context]];
|
||||
}
|
||||
|
||||
[s appendString: @"</Properties>"];
|
||||
@@ -1419,62 +1366,6 @@ static BOOL debugOn = NO;
|
||||
{
|
||||
[theResponse setContent: d];
|
||||
}
|
||||
}
|
||||
else if ([theDocumentElement getElementsByTagName: @"EmptyFolderContents"])
|
||||
{
|
||||
NGImap4Connection *connection;
|
||||
NSEnumerator *subfolders;
|
||||
NSException *error;
|
||||
NSURL *currentURL;
|
||||
id co;
|
||||
|
||||
collectionId = [[(id)[theDocumentElement getElementsByTagName: @"CollectionId"] lastObject] textValue];
|
||||
realCollectionId = [collectionId realCollectionIdWithFolderType: &folderType];
|
||||
realCollectionId = [self globallyUniqueIDToIMAPFolderName: realCollectionId type: folderType];
|
||||
|
||||
if (folderType == ActiveSyncMailFolder)
|
||||
{
|
||||
co = [self collectionFromId: realCollectionId type: folderType];
|
||||
error = [co addFlagsToAllMessages: @"deleted"];
|
||||
|
||||
if (!error)
|
||||
error = [(SOGoMailFolder *)co expunge];
|
||||
|
||||
if (!error)
|
||||
{
|
||||
[co flushMailCaches];
|
||||
|
||||
if ([theDocumentElement getElementsByTagName: @"DeleteSubFolders"])
|
||||
{
|
||||
// Delete sub-folders
|
||||
connection = [co imap4Connection];
|
||||
subfolders = [[co allFolderURLs] objectEnumerator];
|
||||
|
||||
while ((currentURL = [subfolders nextObject]))
|
||||
{
|
||||
[[connection client] unsubscribe: [currentURL path]];
|
||||
[connection deleteMailboxAtURL: currentURL];
|
||||
}
|
||||
}
|
||||
|
||||
[s appendString: @"<Status>1</Status>"];
|
||||
[s appendString: @"</ItemOperations>"];
|
||||
}
|
||||
|
||||
if (error)
|
||||
{
|
||||
[s appendString: @"<Status>3</Status>"];
|
||||
[s appendString: @"</ItemOperations>"];
|
||||
}
|
||||
|
||||
d = [[s dataUsingEncoding: NSUTF8StringEncoding] xml2wbxml];
|
||||
[theResponse setContent: d];
|
||||
}
|
||||
else
|
||||
{
|
||||
[theResponse setStatus: 500];
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -381,6 +381,11 @@ struct GlobalObjectId {
|
||||
|
||||
if (s)
|
||||
{
|
||||
// We sanitize the content immediately, in case we have non-UNICODE safe
|
||||
// characters that would be re-encoded later in HTML entities and thus,
|
||||
// ignore afterwards.
|
||||
s = [s safeString];
|
||||
|
||||
body = [s dataUsingEncoding: NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
@@ -861,41 +866,10 @@ struct GlobalObjectId {
|
||||
|
||||
if (d)
|
||||
{
|
||||
NSMutableData *sanitizedData;
|
||||
NSString *content;
|
||||
int len, truncated;
|
||||
|
||||
// Outlook fails to decode quoted-printable (see #3082) if lines are not termined by CRLF.
|
||||
const char *bytes;
|
||||
char *mbytes;
|
||||
int mlen;
|
||||
|
||||
len = [d length];
|
||||
mlen = 0;
|
||||
|
||||
sanitizedData = [NSMutableData dataWithLength: len*2];
|
||||
|
||||
bytes = [d bytes];
|
||||
mbytes = [sanitizedData mutableBytes];
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
if (*bytes == '\n' && *(bytes-1) != '\r' && mlen > 0)
|
||||
{
|
||||
*mbytes = '\r';
|
||||
mbytes++;
|
||||
mlen++;
|
||||
}
|
||||
|
||||
*mbytes = *bytes;
|
||||
mbytes++; bytes++;
|
||||
len--;
|
||||
mlen++;
|
||||
}
|
||||
|
||||
[sanitizedData setLength: mlen];
|
||||
|
||||
content = [[NSString alloc] initWithData: sanitizedData encoding: NSUTF8StringEncoding];
|
||||
|
||||
content = [[NSString alloc] initWithData: d encoding: NSUTF8StringEncoding];
|
||||
|
||||
// FIXME: This is a hack. We should normally avoid doing this as we might get
|
||||
// broken encodings. We should rather tell that the data was truncated and expect
|
||||
@@ -905,15 +879,15 @@ struct GlobalObjectId {
|
||||
// for an "interesting" discussion around this.
|
||||
//
|
||||
if (!content)
|
||||
content = [[NSString alloc] initWithData: sanitizedData encoding: NSISOLatin1StringEncoding];
|
||||
content = [[NSString alloc] initWithData: d encoding: NSISOLatin1StringEncoding];
|
||||
|
||||
AUTORELEASE(content);
|
||||
|
||||
content = [content activeSyncRepresentationInContext: context];
|
||||
truncated = 0;
|
||||
|
||||
|
||||
len = [content length];
|
||||
|
||||
|
||||
if ([[[context request] headerForKey: @"MS-ASProtocolVersion"] isEqualToString: @"2.5"])
|
||||
{
|
||||
[s appendFormat: @"<Body xmlns=\"Email:\">%@</Body>", content];
|
||||
|
||||
@@ -506,14 +506,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
[self setOrganizer: person];
|
||||
}
|
||||
|
||||
//
|
||||
// iOS is plain stupid here. It seends event invitations with no Organizer.
|
||||
// We check this corner-case and if MeetingStatus == 1 (see http://msdn.microsoft.com/en-us/library/ee219342(v=exchg.80).aspx or details)
|
||||
// and there's no organizer, we fake one.
|
||||
//
|
||||
if ((o = [theValues objectForKey: @"MeetingStatus"]))
|
||||
{
|
||||
//
|
||||
// iOS is plain stupid here. It seends event invitations with no Organizer.
|
||||
// We check this corner-case and if MeetingStatus == 1 (see http://msdn.microsoft.com/en-us/library/ee219342(v=exchg.80).aspx or details)
|
||||
// and there's no organizer, we fake one.
|
||||
//
|
||||
if ([o intValue] == 1 && ![theValues objectForKey: @"Organizer_Email"] && ![[[self organizer] rfc822Email] length])
|
||||
if ([o intValue] == 1 && ![theValues objectForKey: @"Organizer_Email"])
|
||||
{
|
||||
iCalPerson *person;
|
||||
|
||||
@@ -523,20 +523,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
[person setPartStat: @"ACCEPTED"];
|
||||
[self setOrganizer: person];
|
||||
}
|
||||
|
||||
//
|
||||
// When MeetingResponse fails Outlook still sends a new calendar entry with MeetingStatus=3.
|
||||
// Use the organizer from the request if the event has no organizer.
|
||||
//
|
||||
if ([o intValue] == 3 && [theValues objectForKey: @"Organizer_Email"] && ![[[self organizer] rfc822Email] length])
|
||||
{
|
||||
iCalPerson *person;
|
||||
person = [iCalPerson elementWithTag: @"organizer"];
|
||||
[person setEmail: [theValues objectForKey: @"Organizer_Email"]];
|
||||
[person setCn: [theValues objectForKey: @"Organizer_Name"]];
|
||||
[person setPartStat: @"ACCEPTED"];
|
||||
[self setOrganizer: person];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user