IOS-2794 _removeInvalidHeadersFromMessage

IOS-2794
Dirk Zimmermann 2 years ago
parent 977caf2398
commit fee9757a1a

@ -769,35 +769,21 @@
//
- (NSData *) _removeInvalidHeadersFromMessage: (NSData *) theMessage
{
NSMutableData *aMutableData;
NSArray *allLines;
NSUInteger i, count;
// We allocate our mutable data object
aMutableData = [[NSMutableData alloc] initWithCapacity: [theMessage length]];
// We allocate our mutable data object
NSMutableData *aMutableData = [[NSMutableData alloc] initWithCapacity: [theMessage length]];
// We now replace all \n by \r\n
allLines = [theMessage componentsSeparatedByCString: "\n"];
count = [allLines count];
for (i = 0; i < count; i++)
{
NSData *aLine;
// We get a line...
aLine = [allLines objectAtIndex: i];
// We skip dumb headers
if ([aLine hasCPrefix: "From "])
{
continue;
}
// We now replace all \n by \r\n
[theMessage componentsSeparatedByCString:"\n" block:^(NSData *aLine, NSUInteger count) {
// We skip dumb headers
if ([aLine hasCPrefix: "From "]) {
return;
}
[aMutableData appendData: aLine];
[aMutableData appendCString: "\r\n"];
}
[aMutableData appendData: aLine];
[aMutableData appendCString: "\r\n"];
}];
return AUTORELEASE(aMutableData);
return AUTORELEASE(aMutableData);
}
@end

Loading…
Cancel
Save