IOS-791 unwraps UUIDs for clients

IOS-390
buff 5 years ago
parent 4392e2fe56
commit 33eedbe278
  1. 4
      Pantomime.xcodeproj/project.pbxproj
  2. 40
      PantomimeTests/Pantomime/NSData+ExtensionsTest.m
  3. 2
      PantomimeTests/Pantomime/NSData+PantomimeExtensionsTest.m
  4. 11
      pantomime-lib/Framework/Pantomime/CWParser.m
  5. 6
      pantomime-lib/Framework/Pantomime/NSData+Extensions.h
  6. 14
      pantomime-lib/Framework/Pantomime/NSData+Extensions.m

@ -13,6 +13,7 @@
1519EA4C1F2F434200B269A8 /* libPantomimeStatic.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 43980E5B1CBD1B3E00A7FC3C /* libPantomimeStatic.a */; };
1521773A1F22072600C83122 /* CWMIMEUtilityTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 152177381F22072600C83122 /* CWMIMEUtilityTest.m */; };
1521773B1F22072600C83122 /* NSString+ExtensionsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 152177391F22072600C83122 /* NSString+ExtensionsTest.m */; };
1568FEA31FB11C5000993EA3 /* NSData+ExtensionsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 1568FEA21FB11C5000993EA3 /* NSData+ExtensionsTest.m */; };
156926E31FA1E02A00D5F396 /* CWIMAPFolder+CWProtected.m in Sources */ = {isa = PBXBuildFile; fileRef = 15ADD2BF1FA104FD00BA1B9B /* CWIMAPFolder+CWProtected.m */; };
156926E41FA1E03200D5F396 /* CWIMAPFolder+CWProtected.m in Sources */ = {isa = PBXBuildFile; fileRef = 15ADD2BF1FA104FD00BA1B9B /* CWIMAPFolder+CWProtected.m */; };
1598B22A1F6812FC00582157 /* CWInternetAddressTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 1598B2291F6812FC00582157 /* CWInternetAddressTest.m */; };
@ -136,6 +137,7 @@
1519EA4A1F2F3A1500B269A8 /* CWIMAPStoreTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CWIMAPStoreTest.m; sourceTree = "<group>"; };
152177381F22072600C83122 /* CWMIMEUtilityTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CWMIMEUtilityTest.m; sourceTree = "<group>"; };
152177391F22072600C83122 /* NSString+ExtensionsTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+ExtensionsTest.m"; sourceTree = "<group>"; };
1568FEA21FB11C5000993EA3 /* NSData+ExtensionsTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSData+ExtensionsTest.m"; sourceTree = "<group>"; };
1598B2291F6812FC00582157 /* CWInternetAddressTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CWInternetAddressTest.m; sourceTree = "<group>"; };
15ADD2BE1FA104FD00BA1B9B /* CWIMAPFolder+CWProtected.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CWIMAPFolder+CWProtected.h"; sourceTree = "<group>"; };
15ADD2BF1FA104FD00BA1B9B /* CWIMAPFolder+CWProtected.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "CWIMAPFolder+CWProtected.m"; sourceTree = "<group>"; };
@ -304,6 +306,7 @@
1519EA4A1F2F3A1500B269A8 /* CWIMAPStoreTest.m */,
1505D6071F3D9E4A00A04A0B /* NSData+PantomimeExtensionsTest.m */,
1598B2291F6812FC00582157 /* CWInternetAddressTest.m */,
1568FEA21FB11C5000993EA3 /* NSData+ExtensionsTest.m */,
);
path = Pantomime;
sourceTree = "<group>";
@ -789,6 +792,7 @@
433C51B11E6480F400272E19 /* CWMessage.m in Sources */,
4338E3861DF1BD750070176B /* CWContainer.m in Sources */,
4338E3871DF1BD850070176B /* CWFlags.m in Sources */,
1568FEA31FB11C5000993EA3 /* NSData+ExtensionsTest.m in Sources */,
1505D6081F3D9E4A00A04A0B /* NSData+PantomimeExtensionsTest.m in Sources */,
433C51C21E658C8C00272E19 /* CWISO8859_2.m in Sources */,
4338E3851DF1BC880070176B /* CWIMAPFolderTests.m in Sources */,

@ -0,0 +1,40 @@
//
// NSData+ExtensionsTest.m
// PantomimeTests
//
// Created by Andreas Buff on 06.11.17.
// Copyright © 2017 pEp Security S.A. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "NSData+Extensions.h"
@interface NSData_ExtensionsTest : XCTestCase
@end
@implementation NSData_ExtensionsTest
#pragma mark - unwrap
- (void)testUnwrap_wrapped
{
NSString *testStr = @"<35BE75EB.74E6.4CB7.9C5D.432B241FDF90@pretty.Easy.privacy>";
NSString *expected = @"35BE75EB.74E6.4CB7.9C5D.432B241FDF90@pretty.Easy.privacy";
NSData *testData = [testStr dataUsingEncoding:NSUTF8StringEncoding];
NSData *testeeData = [testData unwrap];
NSString* testee = [[NSString alloc] initWithData:testeeData encoding:NSUTF8StringEncoding];
XCTAssertEqualObjects(testee, expected);
}
- (void)testUnwrap_unwrapped
{
NSString *testStr = @"35BE75EB.74E6.4CB7.9C5D.432B241FDF90@pretty.Easy.privacy";
NSString *expected = @"35BE75EB.74E6.4CB7.9C5D.432B241FDF90@pretty.Easy.privacy";
NSData *testData = [testStr dataUsingEncoding:NSUTF8StringEncoding];
NSData *testeeData = [testData unwrap];
NSString* testee = [[NSString alloc] initWithData:testeeData encoding:NSUTF8StringEncoding];
XCTAssertEqualObjects(testee, expected);
}
@end

@ -273,7 +273,7 @@
NSString *expected = key;
NSString *testee = [utf7ImapEncodedData imapUtf7String];
NSLog(@"expected:\t%@\ttestee:\t%@", expected, testee);
XCTAssertTrue([expected isEqualToString:testee]);
}
}

@ -717,15 +717,18 @@ NSRange shrinkRange(NSRange range)
quick: (BOOL) theBOOL
{
NSData *aData;
if (!theBOOL && !([theLine length] > 12))
if (!theBOOL && !([theLine length] > 12))
{
return [NSData data];
}
if (theBOOL) aData = theLine;
else aData = [theLine subdataFromIndex: 12];
aData = [aData unwrap];
[theMessage setMessageID: [[aData dataByTrimmingWhiteSpaces] asciiString]];
return aData;
}

@ -289,6 +289,12 @@
- (NSData *) quoteWithLevel: (NSUInteger) theLevel
wrappingLimit: (NSUInteger) theLimit;
/**
This method is used to unwrap the string which is wrapped with "<" and ">".
@return If wrapped, the unwrapped string as a NSData instance, otherwize the unmodified data.
*/
- (NSData *) unwrap;
/*!
@method unwrapWithLimit:
@discussion This method is used to unwrap the string using a quote limit.

@ -893,6 +893,20 @@ static const char *hexDigit = "0123456789ABCDEF";
}
//
//
//
- (NSData *) unwrap
{
NSData *result = self;
if ([self characterAtIndex: 0] == '<' && [self characterAtIndex: self.length - 1] == '>') {
NSRange rangeWithoutWrappers = NSMakeRange(1, self.length - 2);
result = [self subdataWithRange:rangeWithoutWrappers];
}
return result;
}
//
//
//

Loading…
Cancel
Save