diff --git a/ActiveSync/NGVCard+ActiveSync.m b/ActiveSync/NGVCard+ActiveSync.m index f920ed6c7..7a3d438ef 100644 --- a/ActiveSync/NGVCard+ActiveSync.m +++ b/ActiveSync/NGVCard+ActiveSync.m @@ -42,8 +42,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - (NSString *) activeSyncRepresentation { CardElement *n, *homeAdr, *workAdr; + NSArray *emails, *addresses; NSMutableString *s; - NSArray *emails; id o; int i; @@ -100,44 +100,54 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [s appendFormat: @"%@", o]; // Home Address - homeAdr = [[self childrenWithTag: @"adr" - andAttribute: @"type" - havingValue: @"home"] objectAtIndex: 0]; - - if ((o = [homeAdr flattenedValueAtIndex: 2 forKey: @""])) - [s appendFormat: @"%@", o]; + addresses = [self childrenWithTag: @"adr" + andAttribute: @"type" + havingValue: @"home"]; - if ((o = [homeAdr flattenedValueAtIndex: 3 forKey: @""])) - [s appendFormat: @"%@", o]; + if ([addresses count]) + { + homeAdr = [addresses objectAtIndex: 0]; + + if ((o = [homeAdr flattenedValueAtIndex: 2 forKey: @""])) + [s appendFormat: @"%@", o]; + + if ((o = [homeAdr flattenedValueAtIndex: 3 forKey: @""])) + [s appendFormat: @"%@", o]; + + if ((o = [homeAdr flattenedValueAtIndex: 4 forKey: @""])) + [s appendFormat: @"%@", o]; + + if ((o = [homeAdr flattenedValueAtIndex: 5 forKey: @""])) + [s appendFormat: @"%@", o]; + + if ((o = [homeAdr flattenedValueAtIndex: 6 forKey: @""])) + [s appendFormat: @"%@", o]; + } - if ((o = [homeAdr flattenedValueAtIndex: 4 forKey: @""])) - [s appendFormat: @"%@", o]; - - if ((o = [homeAdr flattenedValueAtIndex: 5 forKey: @""])) - [s appendFormat: @"%@", o]; - - if ((o = [homeAdr flattenedValueAtIndex: 6 forKey: @""])) - [s appendFormat: @"%@", o]; - // Work Address - workAdr = [[self childrenWithTag: @"adr" - andAttribute: @"type" - havingValue: @"work"] objectAtIndex: 0]; + addresses = [self childrenWithTag: @"adr" + andAttribute: @"type" + havingValue: @"work"]; - if ((o = [workAdr flattenedValueAtIndex: 2 forKey: @""])) - [s appendFormat: @"%@", o]; - - if ((o = [workAdr flattenedValueAtIndex: 3 forKey: @""])) - [s appendFormat: @"%@", o]; - - if ((o = [workAdr flattenedValueAtIndex: 4 forKey: @""])) - [s appendFormat: @"%@", o]; - - if ((o = [workAdr flattenedValueAtIndex: 5 forKey: @""])) - [s appendFormat: @"%@", o]; - - if ((o = [workAdr flattenedValueAtIndex: 6 forKey: @""])) - [s appendFormat: @"%@", o]; + if ([addresses count]) + { + workAdr = [addresses objectAtIndex: 0]; + + if ((o = [workAdr flattenedValueAtIndex: 2 forKey: @""])) + [s appendFormat: @"%@", o]; + + if ((o = [workAdr flattenedValueAtIndex: 3 forKey: @""])) + [s appendFormat: @"%@", o]; + + if ((o = [workAdr flattenedValueAtIndex: 4 forKey: @""])) + [s appendFormat: @"%@", o]; + + if ((o = [workAdr flattenedValueAtIndex: 5 forKey: @""])) + [s appendFormat: @"%@", o]; + + if ((o = [workAdr flattenedValueAtIndex: 6 forKey: @""])) + [s appendFormat: @"%@", o]; + } // Other, less important fields if ((o = [self birthday])) diff --git a/ActiveSync/NSData+ActiveSync.m b/ActiveSync/NSData+ActiveSync.m index e964fb086..54c9e1e8a 100644 --- a/ActiveSync/NSData+ActiveSync.m +++ b/ActiveSync/NSData+ActiveSync.m @@ -40,6 +40,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @implementation NSData (ActiveSync) +- (void) _dumpToFile +{ + NSString *path; + + path = [NSString stringWithFormat: @"/tmp/%@.data", [[NSProcessInfo processInfo] globallyUniqueString]]; + [self writeToFile: path atomically: YES]; + NSLog(@"Original data written to: %@", path); +} + - (NSData *) wbxml2xml { WBXMLGenXMLParams params; @@ -62,14 +71,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. if (ret != WBXML_OK) { - NSString *path; - NSLog(@"wbxml2xmlFromContent: failed: %s\n", wbxml_errors_string(ret)); - - path = [NSString stringWithFormat: @"/tmp/%@.data", [[NSProcessInfo processInfo] globallyUniqueString]]; - [self writeToFile: path atomically: YES]; - NSLog(@"Original data written to: %@", path); - + [self _dumpToFile]; return nil; } @@ -103,14 +106,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. if (ret != WBXML_OK) { - NSString *path; - NSLog(@"xml2wbxmlFromContent: failed: %s\n", wbxml_errors_string(ret)); - - path = [NSString stringWithFormat: @"/tmp/%@.data", [[NSProcessInfo processInfo] globallyUniqueString]]; - [self writeToFile: path atomically: YES]; - NSLog(@"Original data written to: %@", path); - + [self _dumpToFile]; return nil; } @@ -125,6 +122,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. if (ret != WBXML_OK) { NSLog(@"xml2wbxmlFromContent: failed: %s\n", wbxml_errors_string(ret)); + [self _dumpToFile]; free(wbxml); wbxml_conv_xml2wbxml_destroy(conv); return nil; diff --git a/ActiveSync/iCalEvent+ActiveSync.m b/ActiveSync/iCalEvent+ActiveSync.m index b6a074e5b..251158c1c 100644 --- a/ActiveSync/iCalEvent+ActiveSync.m +++ b/ActiveSync/iCalEvent+ActiveSync.m @@ -37,6 +37,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #import #import +#import + #import #import #import @@ -135,11 +137,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Subject -- http://msdn.microsoft.com/en-us/library/ee157192(v=exchg.80).aspx if ([[self summary] length]) - [s appendFormat: @"%@", [self summary]]; + [s appendFormat: @"%@", [[self summary] stringByEscapingHTMLString]]; // Location if ([[self location] length]) - [s appendFormat: @"%@", [self location]]; + [s appendFormat: @"%@", [[self location] stringByEscapingHTMLString]]; // Importance - NOT SUPPORTED - DO NOT ENABLE //o = [self priority]; @@ -171,14 +173,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Reminder -- http://msdn.microsoft.com/en-us/library/ee219691(v=exchg.80).aspx // TODO - // Location - if ([[self location] length]) - [s appendFormat: @"%@", [self location]]; - // Comment o = [self comment]; if ([o length]) { + o = [o stringByEscapingHTMLString]; [s appendString: @""]; [s appendFormat: @"%d", 1]; [s appendFormat: @"%d", [o length]]; diff --git a/ActiveSync/iCalToDo+ActiveSync.m b/ActiveSync/iCalToDo+ActiveSync.m index 127e65e30..8e52f3bfb 100644 --- a/ActiveSync/iCalToDo+ActiveSync.m +++ b/ActiveSync/iCalToDo+ActiveSync.m @@ -35,6 +35,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #import #import +#import + #import #import #import @@ -93,10 +95,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [s appendFormat: @"%d", 0]; // Subject - [s appendFormat: @"%@", [self summary]]; + o = [self summary]; + if ([o length]) + [s appendFormat: @"%@", [[self summary] stringByEscapingHTMLString]]; if ((o = [self comment])) { + o = [o stringByEscapingHTMLString]; [s appendString: @""]; [s appendFormat: @"%d", 1]; [s appendFormat: @"%d", [o length]];