From 0d822597a12cf7e2aa4750ac463dfe0e7385eeee Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 28 Mar 2019 16:07:01 -0600 Subject: [PATCH 1/3] specify locale when timestamp parsing --- SignalServiceKit/src/Contacts/ContactDiscoveryService.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/SignalServiceKit/src/Contacts/ContactDiscoveryService.m b/SignalServiceKit/src/Contacts/ContactDiscoveryService.m index 1fe6c1dd7..38565bab8 100644 --- a/SignalServiceKit/src/Contacts/ContactDiscoveryService.m +++ b/SignalServiceKit/src/Contacts/ContactDiscoveryService.m @@ -624,6 +624,15 @@ NSError *ContactDiscoveryServiceErrorMakeWithReason(NSInteger code, NSString *re NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"UTC"]; [dateFormatter setTimeZone:timeZone]; [dateFormatter setDateFormat:@"yyy-MM-dd'T'HH:mm:ss.SSSSSS"]; + + // Specify parsing locale + // from: https://developer.apple.com/library/archive/qa/qa1480/_index.html + // Q: I'm using NSDateFormatter to parse an Internet-style date, but this fails for some users in some regions. + // I've set a specific date format string; shouldn't that force NSDateFormatter to work independently of the user's + // region settings? A: No. While setting a date format string will appear to work for most users, it's not the right + // solution to this problem. There are many places where format strings behave in unexpected ways. [...] + NSLocale *enUSPOSIXLocale = [NSLocale localeWithLocaleIdentifier:@"en_US_POSIX"]; + [dateFormatter setLocale:enUSPOSIXLocale]; NSDate *timestampDate = [dateFormatter dateFromString:signatureBodyEntity.timestamp]; if (!timestampDate) { OWSFailDebug(@"Could not parse signature body timestamp: %@", signatureBodyEntity.timestamp); From 5e52d66b05b35968cc2e104e96c494b424353e8d Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 28 Mar 2019 16:28:26 -0600 Subject: [PATCH 2/3] bump feedback endpoint --- SignalServiceKit/src/Network/API/Requests/OWSRequestFactory.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SignalServiceKit/src/Network/API/Requests/OWSRequestFactory.m b/SignalServiceKit/src/Network/API/Requests/OWSRequestFactory.m index ab4dd9017..68214a7d7 100644 --- a/SignalServiceKit/src/Network/API/Requests/OWSRequestFactory.m +++ b/SignalServiceKit/src/Network/API/Requests/OWSRequestFactory.m @@ -516,7 +516,7 @@ NS_ASSUME_NONNULL_BEGIN } parameters = @{ @"reason": limitedReason }; } - NSString *path = [NSString stringWithFormat:@"/v1/directory/feedback-v2/%@", status]; + NSString *path = [NSString stringWithFormat:@"/v1/directory/feedback-v3/%@", status]; return [TSRequest requestWithUrl:[NSURL URLWithString:path] method:@"PUT" parameters:parameters]; } From 048f19c6b8f065d568bffc4f0ea2e475eaeaab58 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 28 Mar 2019 16:31:06 -0600 Subject: [PATCH 3/3] specify yyyy date format --- SignalServiceKit/src/Contacts/ContactDiscoveryService.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SignalServiceKit/src/Contacts/ContactDiscoveryService.m b/SignalServiceKit/src/Contacts/ContactDiscoveryService.m index 38565bab8..7c04e333e 100644 --- a/SignalServiceKit/src/Contacts/ContactDiscoveryService.m +++ b/SignalServiceKit/src/Contacts/ContactDiscoveryService.m @@ -623,7 +623,7 @@ NSError *ContactDiscoveryServiceErrorMakeWithReason(NSInteger code, NSString *re NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"UTC"]; [dateFormatter setTimeZone:timeZone]; - [dateFormatter setDateFormat:@"yyy-MM-dd'T'HH:mm:ss.SSSSSS"]; + [dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSSSS"]; // Specify parsing locale // from: https://developer.apple.com/library/archive/qa/qa1480/_index.html