Properly escape fields and improved data dumps.
parent
7b97e28cff
commit
3b7a3c94d4
|
@ -42,8 +42,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
- (NSString *) activeSyncRepresentation
|
- (NSString *) activeSyncRepresentation
|
||||||
{
|
{
|
||||||
CardElement *n, *homeAdr, *workAdr;
|
CardElement *n, *homeAdr, *workAdr;
|
||||||
|
NSArray *emails, *addresses;
|
||||||
NSMutableString *s;
|
NSMutableString *s;
|
||||||
NSArray *emails;
|
|
||||||
id o;
|
id o;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
@ -100,44 +100,54 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
[s appendFormat: @"<PagerNumber xmlns=\"Contacts:\">%@</PagerNumber>", o];
|
[s appendFormat: @"<PagerNumber xmlns=\"Contacts:\">%@</PagerNumber>", o];
|
||||||
|
|
||||||
// Home Address
|
// Home Address
|
||||||
homeAdr = [[self childrenWithTag: @"adr"
|
addresses = [self childrenWithTag: @"adr"
|
||||||
andAttribute: @"type"
|
andAttribute: @"type"
|
||||||
havingValue: @"home"] objectAtIndex: 0];
|
havingValue: @"home"];
|
||||||
|
|
||||||
if ((o = [homeAdr flattenedValueAtIndex: 2 forKey: @""]))
|
|
||||||
[s appendFormat: @"<HomeStreet xmlns=\"Contacts:\">%@</HomeStreet>", o];
|
|
||||||
|
|
||||||
if ((o = [homeAdr flattenedValueAtIndex: 3 forKey: @""]))
|
if ([addresses count])
|
||||||
[s appendFormat: @"<HomeCity xmlns=\"Contacts:\">%@</HomeCity>", o];
|
{
|
||||||
|
homeAdr = [addresses objectAtIndex: 0];
|
||||||
|
|
||||||
|
if ((o = [homeAdr flattenedValueAtIndex: 2 forKey: @""]))
|
||||||
|
[s appendFormat: @"<HomeStreet xmlns=\"Contacts:\">%@</HomeStreet>", o];
|
||||||
|
|
||||||
|
if ((o = [homeAdr flattenedValueAtIndex: 3 forKey: @""]))
|
||||||
|
[s appendFormat: @"<HomeCity xmlns=\"Contacts:\">%@</HomeCity>", o];
|
||||||
|
|
||||||
|
if ((o = [homeAdr flattenedValueAtIndex: 4 forKey: @""]))
|
||||||
|
[s appendFormat: @"<HomeState xmlns=\"Contacts:\">%@</HomeState>", o];
|
||||||
|
|
||||||
|
if ((o = [homeAdr flattenedValueAtIndex: 5 forKey: @""]))
|
||||||
|
[s appendFormat: @"<HomePostalCode xmlns=\"Contacts:\">%@</HomePostalCode>", o];
|
||||||
|
|
||||||
|
if ((o = [homeAdr flattenedValueAtIndex: 6 forKey: @""]))
|
||||||
|
[s appendFormat: @"<HomeCountry xmlns=\"Contacts:\">%@</HomeCountry>", o];
|
||||||
|
}
|
||||||
|
|
||||||
if ((o = [homeAdr flattenedValueAtIndex: 4 forKey: @""]))
|
|
||||||
[s appendFormat: @"<HomeState xmlns=\"Contacts:\">%@</HomeState>", o];
|
|
||||||
|
|
||||||
if ((o = [homeAdr flattenedValueAtIndex: 5 forKey: @""]))
|
|
||||||
[s appendFormat: @"<HomePostalCode xmlns=\"Contacts:\">%@</HomePostalCode>", o];
|
|
||||||
|
|
||||||
if ((o = [homeAdr flattenedValueAtIndex: 6 forKey: @""]))
|
|
||||||
[s appendFormat: @"<HomeCountry xmlns=\"Contacts:\">%@</HomeCountry>", o];
|
|
||||||
|
|
||||||
// Work Address
|
// Work Address
|
||||||
workAdr = [[self childrenWithTag: @"adr"
|
addresses = [self childrenWithTag: @"adr"
|
||||||
andAttribute: @"type"
|
andAttribute: @"type"
|
||||||
havingValue: @"work"] objectAtIndex: 0];
|
havingValue: @"work"];
|
||||||
|
|
||||||
if ((o = [workAdr flattenedValueAtIndex: 2 forKey: @""]))
|
if ([addresses count])
|
||||||
[s appendFormat: @"<BusinessStreet xmlns=\"Contacts:\">%@</BusinessStreet>", o];
|
{
|
||||||
|
workAdr = [addresses objectAtIndex: 0];
|
||||||
if ((o = [workAdr flattenedValueAtIndex: 3 forKey: @""]))
|
|
||||||
[s appendFormat: @"<BusinessCity xmlns=\"Contacts:\">%@</BusinessCity>", o];
|
if ((o = [workAdr flattenedValueAtIndex: 2 forKey: @""]))
|
||||||
|
[s appendFormat: @"<BusinessStreet xmlns=\"Contacts:\">%@</BusinessStreet>", o];
|
||||||
if ((o = [workAdr flattenedValueAtIndex: 4 forKey: @""]))
|
|
||||||
[s appendFormat: @"<BusinessState xmlns=\"Contacts:\">%@</BusinessState>", o];
|
if ((o = [workAdr flattenedValueAtIndex: 3 forKey: @""]))
|
||||||
|
[s appendFormat: @"<BusinessCity xmlns=\"Contacts:\">%@</BusinessCity>", o];
|
||||||
if ((o = [workAdr flattenedValueAtIndex: 5 forKey: @""]))
|
|
||||||
[s appendFormat: @"<BusinessPostalCode xmlns=\"Contacts:\">%@</BusinessPostalCode>", o];
|
if ((o = [workAdr flattenedValueAtIndex: 4 forKey: @""]))
|
||||||
|
[s appendFormat: @"<BusinessState xmlns=\"Contacts:\">%@</BusinessState>", o];
|
||||||
if ((o = [workAdr flattenedValueAtIndex: 6 forKey: @""]))
|
|
||||||
[s appendFormat: @"<BusinessCountry xmlns=\"Contacts:\">%@</BusinessCountry>", o];
|
if ((o = [workAdr flattenedValueAtIndex: 5 forKey: @""]))
|
||||||
|
[s appendFormat: @"<BusinessPostalCode xmlns=\"Contacts:\">%@</BusinessPostalCode>", o];
|
||||||
|
|
||||||
|
if ((o = [workAdr flattenedValueAtIndex: 6 forKey: @""]))
|
||||||
|
[s appendFormat: @"<BusinessCountry xmlns=\"Contacts:\">%@</BusinessCountry>", o];
|
||||||
|
}
|
||||||
|
|
||||||
// Other, less important fields
|
// Other, less important fields
|
||||||
if ((o = [self birthday]))
|
if ((o = [self birthday]))
|
||||||
|
|
|
@ -40,6 +40,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
@implementation NSData (ActiveSync)
|
@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
|
- (NSData *) wbxml2xml
|
||||||
{
|
{
|
||||||
WBXMLGenXMLParams params;
|
WBXMLGenXMLParams params;
|
||||||
|
@ -62,14 +71,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
if (ret != WBXML_OK)
|
if (ret != WBXML_OK)
|
||||||
{
|
{
|
||||||
NSString *path;
|
|
||||||
|
|
||||||
NSLog(@"wbxml2xmlFromContent: failed: %s\n", wbxml_errors_string(ret));
|
NSLog(@"wbxml2xmlFromContent: failed: %s\n", wbxml_errors_string(ret));
|
||||||
|
[self _dumpToFile];
|
||||||
path = [NSString stringWithFormat: @"/tmp/%@.data", [[NSProcessInfo processInfo] globallyUniqueString]];
|
|
||||||
[self writeToFile: path atomically: YES];
|
|
||||||
NSLog(@"Original data written to: %@", path);
|
|
||||||
|
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,14 +106,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
if (ret != WBXML_OK)
|
if (ret != WBXML_OK)
|
||||||
{
|
{
|
||||||
NSString *path;
|
|
||||||
|
|
||||||
NSLog(@"xml2wbxmlFromContent: failed: %s\n", wbxml_errors_string(ret));
|
NSLog(@"xml2wbxmlFromContent: failed: %s\n", wbxml_errors_string(ret));
|
||||||
|
[self _dumpToFile];
|
||||||
path = [NSString stringWithFormat: @"/tmp/%@.data", [[NSProcessInfo processInfo] globallyUniqueString]];
|
|
||||||
[self writeToFile: path atomically: YES];
|
|
||||||
NSLog(@"Original data written to: %@", path);
|
|
||||||
|
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,6 +122,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
if (ret != WBXML_OK)
|
if (ret != WBXML_OK)
|
||||||
{
|
{
|
||||||
NSLog(@"xml2wbxmlFromContent: failed: %s\n", wbxml_errors_string(ret));
|
NSLog(@"xml2wbxmlFromContent: failed: %s\n", wbxml_errors_string(ret));
|
||||||
|
[self _dumpToFile];
|
||||||
free(wbxml);
|
free(wbxml);
|
||||||
wbxml_conv_xml2wbxml_destroy(conv);
|
wbxml_conv_xml2wbxml_destroy(conv);
|
||||||
return nil;
|
return nil;
|
||||||
|
|
|
@ -37,6 +37,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#import <Foundation/NSString.h>
|
#import <Foundation/NSString.h>
|
||||||
#import <Foundation/NSTimeZone.h>
|
#import <Foundation/NSTimeZone.h>
|
||||||
|
|
||||||
|
#import <NGExtensions/NSString+misc.h>
|
||||||
|
|
||||||
#import <NGCards/iCalCalendar.h>
|
#import <NGCards/iCalCalendar.h>
|
||||||
#import <NGCards/iCalDateTime.h>
|
#import <NGCards/iCalDateTime.h>
|
||||||
#import <NGCards/iCalPerson.h>
|
#import <NGCards/iCalPerson.h>
|
||||||
|
@ -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
|
// Subject -- http://msdn.microsoft.com/en-us/library/ee157192(v=exchg.80).aspx
|
||||||
if ([[self summary] length])
|
if ([[self summary] length])
|
||||||
[s appendFormat: @"<Subject xmlns=\"Calendar:\">%@</Subject>", [self summary]];
|
[s appendFormat: @"<Subject xmlns=\"Calendar:\">%@</Subject>", [[self summary] stringByEscapingHTMLString]];
|
||||||
|
|
||||||
// Location
|
// Location
|
||||||
if ([[self location] length])
|
if ([[self location] length])
|
||||||
[s appendFormat: @"<Location xmlns=\"Calendar:\">%@</Location>", [self location]];
|
[s appendFormat: @"<Location xmlns=\"Calendar:\">%@</Location>", [[self location] stringByEscapingHTMLString]];
|
||||||
|
|
||||||
// Importance - NOT SUPPORTED - DO NOT ENABLE
|
// Importance - NOT SUPPORTED - DO NOT ENABLE
|
||||||
//o = [self priority];
|
//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
|
// Reminder -- http://msdn.microsoft.com/en-us/library/ee219691(v=exchg.80).aspx
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
// Location
|
|
||||||
if ([[self location] length])
|
|
||||||
[s appendFormat: @"<Location xmlns=\"Calendar:\">%@</Location>", [self location]];
|
|
||||||
|
|
||||||
// Comment
|
// Comment
|
||||||
o = [self comment];
|
o = [self comment];
|
||||||
if ([o length])
|
if ([o length])
|
||||||
{
|
{
|
||||||
|
o = [o stringByEscapingHTMLString];
|
||||||
[s appendString: @"<Body xmlns=\"AirSyncBase:\">"];
|
[s appendString: @"<Body xmlns=\"AirSyncBase:\">"];
|
||||||
[s appendFormat: @"<Type>%d</Type>", 1];
|
[s appendFormat: @"<Type>%d</Type>", 1];
|
||||||
[s appendFormat: @"<EstimatedDataSize>%d</EstimatedDataSize>", [o length]];
|
[s appendFormat: @"<EstimatedDataSize>%d</EstimatedDataSize>", [o length]];
|
||||||
|
|
|
@ -35,6 +35,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#import <Foundation/NSString.h>
|
#import <Foundation/NSString.h>
|
||||||
#import <Foundation/NSTimeZone.h>
|
#import <Foundation/NSTimeZone.h>
|
||||||
|
|
||||||
|
#import <NGExtensions/NSString+misc.h>
|
||||||
|
|
||||||
#import <NGCards/iCalCalendar.h>
|
#import <NGCards/iCalCalendar.h>
|
||||||
#import <NGCards/iCalDateTime.h>
|
#import <NGCards/iCalDateTime.h>
|
||||||
#import <NGCards/iCalTimeZone.h>
|
#import <NGCards/iCalTimeZone.h>
|
||||||
|
@ -93,10 +95,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
[s appendFormat: @"<Sensitivity xmlns=\"Tasks:\">%d</Sensitivity>", 0];
|
[s appendFormat: @"<Sensitivity xmlns=\"Tasks:\">%d</Sensitivity>", 0];
|
||||||
|
|
||||||
// Subject
|
// Subject
|
||||||
[s appendFormat: @"<Subject xmlns=\"Tasks:\">%@</Subject>", [self summary]];
|
o = [self summary];
|
||||||
|
if ([o length])
|
||||||
|
[s appendFormat: @"<Subject xmlns=\"Tasks:\">%@</Subject>", [[self summary] stringByEscapingHTMLString]];
|
||||||
|
|
||||||
if ((o = [self comment]))
|
if ((o = [self comment]))
|
||||||
{
|
{
|
||||||
|
o = [o stringByEscapingHTMLString];
|
||||||
[s appendString: @"<Body xmlns=\"AirSyncBase:\">"];
|
[s appendString: @"<Body xmlns=\"AirSyncBase:\">"];
|
||||||
[s appendFormat: @"<Type>%d</Type>", 1];
|
[s appendFormat: @"<Type>%d</Type>", 1];
|
||||||
[s appendFormat: @"<EstimatedDataSize>%d</EstimatedDataSize>", [o length]];
|
[s appendFormat: @"<EstimatedDataSize>%d</EstimatedDataSize>", [o length]];
|
||||||
|
|
Loading…
Reference in New Issue