Skip to content

Commit

Permalink
Merge pull request #764 from bugsnag/release-v5.23.5
Browse files Browse the repository at this point in the history
Release v5.23.5
  • Loading branch information
tomlongridge authored Jul 27, 2020
2 parents c37bf52 + fb1276f commit c64b617
Show file tree
Hide file tree
Showing 16 changed files with 199 additions and 57 deletions.
4 changes: 2 additions & 2 deletions Bugsnag.podspec.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Bugsnag",
"version": "5.23.4",
"version": "5.23.5",
"summary": "Cocoa notifier for SDK for bugsnag.com",
"homepage": "https://bugsnag.com",
"license": "MIT",
Expand All @@ -9,7 +9,7 @@
},
"source": {
"git": "https://github.com/bugsnag/bugsnag-cocoa.git",
"tag": "v5.23.4"
"tag": "v5.23.5"
},
"frameworks": ["Foundation", "SystemConfiguration"],
"libraries": [
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
Changelog
=========

## 5.23.5 (2020-07-27)

### Bug fixes

The following bug fixes have been applied to the v5 branch to provide a patch
for users who have not yet upgraded to v6:

* Fix JSON serialisation of strings with control characters
[739](https://github.com/bugsnag/bugsnag-cocoa/pull/739)

* Removed non-thread safe date formatter
[#758](https://github.com/bugsnag/bugsnag-cocoa/pull/758)

## 5.23.4 (2020-07-06)

### Bug Fixes
Expand Down
16 changes: 8 additions & 8 deletions OSX/Bugsnag.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
8A87352C1C6D3B1600EDBD5B /* BSG_KSCrashReportWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A87352B1C6D3B1600EDBD5B /* BSG_KSCrashReportWriter.h */; settings = {ATTRIBUTES = (Public, ); }; };
8ACF0F752018136200173809 /* BugsnagCrashReportTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A2C8FE11C6BC38200846019 /* BugsnagCrashReportTests.m */; };
8AD9FA891E086351002859A7 /* BugsnagConfigurationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AD9FA851E0862DC002859A7 /* BugsnagConfigurationTests.m */; };
E694862324CB1C5F002077D1 /* BSG_RFC3339DateTool.m in Sources */ = {isa = PBXBuildFile; fileRef = E694862124CB1C5F002077D1 /* BSG_RFC3339DateTool.m */; };
E694862424CB1C5F002077D1 /* BSG_RFC3339DateTool.h in Headers */ = {isa = PBXBuildFile; fileRef = E694862224CB1C5F002077D1 /* BSG_RFC3339DateTool.h */; };
E72352C11F55924A00436528 /* BSGConnectivity.h in Headers */ = {isa = PBXBuildFile; fileRef = E72352BF1F55924A00436528 /* BSGConnectivity.h */; };
E72352C21F55924A00436528 /* BSGConnectivity.m in Sources */ = {isa = PBXBuildFile; fileRef = E72352C01F55924A00436528 /* BSGConnectivity.m */; };
E7433AD21F4F64EF00C082D1 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 8A2C8FF11C6BC3A800846019 /* libz.tbd */; };
Expand Down Expand Up @@ -149,8 +151,6 @@
E79E6BD01F4E3850002B35F9 /* BSG_KSSysCtl.h in Headers */ = {isa = PBXBuildFile; fileRef = E79E6B641F4E3850002B35F9 /* BSG_KSSysCtl.h */; };
E79E6BD51F4E3850002B35F9 /* NSError+BSG_SimpleConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = E79E6B691F4E3850002B35F9 /* NSError+BSG_SimpleConstructor.h */; };
E79E6BD61F4E3850002B35F9 /* NSError+BSG_SimpleConstructor.m in Sources */ = {isa = PBXBuildFile; fileRef = E79E6B6A1F4E3850002B35F9 /* NSError+BSG_SimpleConstructor.m */; };
E79E6BD91F4E3850002B35F9 /* BSG_RFC3339DateTool.h in Headers */ = {isa = PBXBuildFile; fileRef = E79E6B6D1F4E3850002B35F9 /* BSG_RFC3339DateTool.h */; };
E79E6BDA1F4E3850002B35F9 /* BSG_RFC3339DateTool.m in Sources */ = {isa = PBXBuildFile; fileRef = E79E6B6E1F4E3850002B35F9 /* BSG_RFC3339DateTool.m */; };
E79E6BDB1F4E3850002B35F9 /* BSG_KSCrashReportFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = E79E6B711F4E3850002B35F9 /* BSG_KSCrashReportFilter.h */; };
E79E6BDC1F4E3850002B35F9 /* BSG_KSCrashReportFilterCompletion.h in Headers */ = {isa = PBXBuildFile; fileRef = E79E6B721F4E3850002B35F9 /* BSG_KSCrashReportFilterCompletion.h */; };
E7CE78BB1FD94E77001D07E0 /* KSCrashReportConverter_Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = E7CE78991FD94E60001D07E0 /* KSCrashReportConverter_Tests.m */; };
Expand Down Expand Up @@ -231,6 +231,8 @@
8A6C6FB02257884C00E8EF24 /* BSGOutOfMemoryWatchdog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BSGOutOfMemoryWatchdog.h; path = ../Source/BSGOutOfMemoryWatchdog.h; sourceTree = "<group>"; };
8A87352B1C6D3B1600EDBD5B /* BSG_KSCrashReportWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BSG_KSCrashReportWriter.h; path = ../Source/BSG_KSCrashReportWriter.h; sourceTree = SOURCE_ROOT; };
8AD9FA851E0862DC002859A7 /* BugsnagConfigurationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BugsnagConfigurationTests.m; path = ../Tests/BugsnagConfigurationTests.m; sourceTree = SOURCE_ROOT; };
E694862124CB1C5F002077D1 /* BSG_RFC3339DateTool.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BSG_RFC3339DateTool.m; path = ../Source/BSG_RFC3339DateTool.m; sourceTree = "<group>"; };
E694862224CB1C5F002077D1 /* BSG_RFC3339DateTool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BSG_RFC3339DateTool.h; path = ../Source/BSG_RFC3339DateTool.h; sourceTree = "<group>"; };
E72352BF1F55924A00436528 /* BSGConnectivity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BSGConnectivity.h; path = ../Source/BSGConnectivity.h; sourceTree = SOURCE_ROOT; };
E72352C01F55924A00436528 /* BSGConnectivity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BSGConnectivity.m; path = ../Source/BSGConnectivity.m; sourceTree = SOURCE_ROOT; };
E762E9F71F73F7E900E82B43 /* BugsnagHandledStateTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BugsnagHandledStateTest.m; path = ../Tests/BugsnagHandledStateTest.m; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -335,8 +337,6 @@
E79E6B641F4E3850002B35F9 /* BSG_KSSysCtl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BSG_KSSysCtl.h; path = ../Source/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSSysCtl.h; sourceTree = SOURCE_ROOT; };
E79E6B691F4E3850002B35F9 /* NSError+BSG_SimpleConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSError+BSG_SimpleConstructor.h"; path = "../Source/KSCrash/Source/KSCrash/Recording/Tools/NSError+BSG_SimpleConstructor.h"; sourceTree = SOURCE_ROOT; };
E79E6B6A1F4E3850002B35F9 /* NSError+BSG_SimpleConstructor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSError+BSG_SimpleConstructor.m"; path = "../Source/KSCrash/Source/KSCrash/Recording/Tools/NSError+BSG_SimpleConstructor.m"; sourceTree = SOURCE_ROOT; };
E79E6B6D1F4E3850002B35F9 /* BSG_RFC3339DateTool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BSG_RFC3339DateTool.h; path = ../Source/KSCrash/Source/KSCrash/Recording/Tools/BSG_RFC3339DateTool.h; sourceTree = SOURCE_ROOT; };
E79E6B6E1F4E3850002B35F9 /* BSG_RFC3339DateTool.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BSG_RFC3339DateTool.m; path = ../Source/KSCrash/Source/KSCrash/Recording/Tools/BSG_RFC3339DateTool.m; sourceTree = SOURCE_ROOT; };
E79E6B711F4E3850002B35F9 /* BSG_KSCrashReportFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BSG_KSCrashReportFilter.h; path = ../Source/KSCrash/Source/KSCrash/Reporting/Filters/BSG_KSCrashReportFilter.h; sourceTree = SOURCE_ROOT; };
E79E6B721F4E3850002B35F9 /* BSG_KSCrashReportFilterCompletion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BSG_KSCrashReportFilterCompletion.h; path = ../Source/KSCrash/Source/KSCrash/Reporting/Filters/BSG_KSCrashReportFilterCompletion.h; sourceTree = SOURCE_ROOT; };
E7CE78871FD94E5F001D07E0 /* KSMach_Tests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KSMach_Tests.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -409,6 +409,8 @@
8A3C591123968B3600B344AA /* BugsnagPlugin.h */,
8A6C6FB02257884C00E8EF24 /* BSGOutOfMemoryWatchdog.h */,
8A6C6FAF2257884C00E8EF24 /* BSGOutOfMemoryWatchdog.m */,
E694862224CB1C5F002077D1 /* BSG_RFC3339DateTool.h */,
E694862124CB1C5F002077D1 /* BSG_RFC3339DateTool.m */,
E791483E1FD82B35003EFEBF /* BugsnagApiClient.h */,
E791483D1FD82B35003EFEBF /* BugsnagApiClient.m */,
E79148401FD82B35003EFEBF /* BugsnagFileStore.h */,
Expand Down Expand Up @@ -623,8 +625,6 @@
E79E6B641F4E3850002B35F9 /* BSG_KSSysCtl.h */,
E79E6B691F4E3850002B35F9 /* NSError+BSG_SimpleConstructor.h */,
E79E6B6A1F4E3850002B35F9 /* NSError+BSG_SimpleConstructor.m */,
E79E6B6D1F4E3850002B35F9 /* BSG_RFC3339DateTool.h */,
E79E6B6E1F4E3850002B35F9 /* BSG_RFC3339DateTool.m */,
);
name = Tools;
path = ../Source/KSCrash/Source/KSCrash/Recording/Tools;
Expand Down Expand Up @@ -751,8 +751,8 @@
E79E6BC61F4E3850002B35F9 /* BSG_KSObjC.h in Headers */,
E79E6BCE1F4E3850002B35F9 /* BSG_KSString.h in Headers */,
E79E6B921F4E3850002B35F9 /* BSG_KSCrashReportFields.h in Headers */,
E79E6BD91F4E3850002B35F9 /* BSG_RFC3339DateTool.h in Headers */,
E72352C11F55924A00436528 /* BSGConnectivity.h in Headers */,
E694862424CB1C5F002077D1 /* BSG_RFC3339DateTool.h in Headers */,
8A2C8FDD1C6BC2C800846019 /* BugsnagSink.h in Headers */,
8A87352C1C6D3B1600EDBD5B /* BSG_KSCrashReportWriter.h in Headers */,
E79148461FD82B36003EFEBF /* BugsnagSession.h in Headers */,
Expand Down Expand Up @@ -860,6 +860,7 @@
files = (
E79E6BCD1F4E3850002B35F9 /* BSG_KSString.c in Sources */,
E79E6BCF1F4E3850002B35F9 /* BSG_KSSysCtl.c in Sources */,
E694862324CB1C5F002077D1 /* BSG_RFC3339DateTool.m in Sources */,
8A2C8FD41C6BC2C800846019 /* BugsnagConfiguration.m in Sources */,
8A627CDA1EC3B75200F7C04E /* BSGSerialization.m in Sources */,
E79E6BAA1F4E3850002B35F9 /* BSG_KSCrashSentry_Signal.c in Sources */,
Expand Down Expand Up @@ -912,7 +913,6 @@
E79E6B891F4E3850002B35F9 /* BSG_KSCrash.m in Sources */,
E79E6BAC1F4E3850002B35F9 /* BSG_KSCrashSentry_User.c in Sources */,
E79148581FD82B36003EFEBF /* BugsnagFileStore.m in Sources */,
E79E6BDA1F4E3850002B35F9 /* BSG_RFC3339DateTool.m in Sources */,
E72352C21F55924A00436528 /* BSGConnectivity.m in Sources */,
8A530CB922FDC38300F0C108 /* BSG_KSCrashIdentifier.m in Sources */,
);
Expand Down
5 changes: 3 additions & 2 deletions Source/BSGOutOfMemoryWatchdog.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#import "Bugsnag.h"
#import "BugsnagKSCrashSysInfoParser.h"
#import "BugsnagSessionTracker.h"
#import "BSG_RFC3339DateTool.h"

@interface BSGOutOfMemoryWatchdog ()
@property(nonatomic, getter=isWatching) BOOL watching;
Expand Down Expand Up @@ -144,8 +145,8 @@ - (void)handleTransitionToBackground:(NSNotification *)note {
}

- (void)handleLowMemoryChange:(NSNotification *)note {
self.cachedFileInfo[@"device"][@"lowMemory"] = [[Bugsnag payloadDateFormatter]
stringFromDate:[NSDate date]];
self.cachedFileInfo[@"device"][@"lowMemory"] =
[BSG_RFC3339DateTool stringFromDate:[NSDate date]];
[self writeSentinelFile];
}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,18 @@

#import "BSG_RFC3339DateTool.h"

@interface BSG_RFC3339DateTool ()
+ (NSDateFormatter *)iosFormatterInstance;
@end

@implementation BSG_RFC3339DateTool

static NSString *const kDateFormatterKey = @"RfcDateFormatter";
static NSString *const kRfcDateFormatterKey = @"RfcDateFormatter";
static NSString *const kIsoDateFormatterKey = @"IsoDateFormatter";

+ (NSDateFormatter *)sharedInstance {
NSMutableDictionary *threadDict = [[NSThread currentThread] threadDictionary];
NSDateFormatter *formatter = threadDict[kDateFormatterKey];
NSDateFormatter *formatter = threadDict[kRfcDateFormatterKey];

if (formatter == nil) {
formatter = [NSDateFormatter new];
Expand All @@ -39,8 +44,30 @@ + (NSDateFormatter *)sharedInstance {
[formatter setLocale:locale];
[formatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"];
[formatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
threadDict[kDateFormatterKey] = formatter;
threadDict[kRfcDateFormatterKey] = formatter;
}

formatter = threadDict[kRfcDateFormatterKey];
return formatter;
}

/**
Used internally to convert any dates with timezones (from older notifier versions) to Zulu time
*/
+ (NSDateFormatter *)iosFormatterInstance {
NSMutableDictionary *threadDict = [[NSThread currentThread] threadDictionary];
NSDateFormatter *formatter = threadDict[kIsoDateFormatterKey];
if (formatter == nil) {
formatter = [NSDateFormatter new];
NSLocale *locale =
[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
[formatter setLocale:locale];
[formatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ssZZZ"];
[formatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
threadDict[kIsoDateFormatterKey] = formatter;
}

formatter = threadDict[kIsoDateFormatterKey];
return formatter;
}

Expand All @@ -55,7 +82,11 @@ + (NSDate *)dateFromString:(NSString *)string {
if (![string isKindOfClass:[NSString class]]) {
return nil;
}
return [[self sharedInstance] dateFromString:string];
NSDate *date = [[self sharedInstance] dateFromString:string];
if (!date) {
date = [[self iosFormatterInstance] dateFromString:string];
}
return date;
}

+ (NSString *)stringFromUNIXTimestamp:(unsigned long long)timestamp {
Expand Down
2 changes: 0 additions & 2 deletions Source/Bugsnag.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,6 @@ static NSString *_Nonnull const BugsnagSeverityInfo = @"info";
*/
+ (void)clearBreadcrumbs;

+ (NSDateFormatter *_Nonnull)payloadDateFormatter;

+ (void)setSuspendThreadsForUserReported:(BOOL)suspendThreadsForUserReported;
+ (void)setReportWhenDebuggerIsAttached:(BOOL)reportWhenDebuggerIsAttached;
+ (void)setThreadTracingEnabled:(BOOL)threadTracingEnabled;
Expand Down
10 changes: 0 additions & 10 deletions Source/Bugsnag.m
Original file line number Diff line number Diff line change
Expand Up @@ -266,16 +266,6 @@ + (BOOL)resumeSession {
}
}

+ (NSDateFormatter *)payloadDateFormatter {
static NSDateFormatter *formatter;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
formatter = [NSDateFormatter new];
formatter.dateFormat = @"yyyy'-'MM'-'dd'T'HH':'mm':'ssZZZ";
});
return formatter;
}

+ (void)setSuspendThreadsForUserReported:(BOOL)suspendThreadsForUserReported {
if ([self bugsnagStarted]) {
[[BSG_KSCrash sharedInstance]
Expand Down
3 changes: 2 additions & 1 deletion Source/BugsnagBreadcrumb.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#import "Bugsnag.h"
#import "BugsnagLogger.h"
#import "BugsnagKeys.h"
#import "BSG_RFC3339DateTool.h"

static NSString *const BSGBreadcrumbDefaultName = @"manual";
static NSUInteger const BSGBreadcrumbMaxByteSize = 4096;
Expand Down Expand Up @@ -82,7 +83,7 @@ - (BOOL)isValid {
- (NSDictionary *)objectValue {
@synchronized (self) {
NSString *timestamp =
[[Bugsnag payloadDateFormatter] stringFromDate:_timestamp];
[BSG_RFC3339DateTool stringFromDate:_timestamp];
if (timestamp && _name.length > 0) {
NSMutableDictionary *metadata = [NSMutableDictionary new];
for (NSString *key in _metadata) {
Expand Down
5 changes: 2 additions & 3 deletions Source/BugsnagNotifier.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#import <AppKit/AppKit.h>
#endif

NSString *const NOTIFIER_VERSION = @"5.23.4";
NSString *const NOTIFIER_VERSION = @"5.23.5";
NSString *const NOTIFIER_URL = @"https://github.com/bugsnag/bugsnag-cocoa";
NSString *const BSTabCrash = @"crash";
NSString *const BSAttributeDepth = @"depth";
Expand Down Expand Up @@ -802,8 +802,7 @@ - (void)orientationChanged:(NSNotification *)notif {

- (void)lowMemoryWarning:(NSNotification *)notif {
[[self state] addAttribute:BSEventLowMemoryWarning
withValue:[[Bugsnag payloadDateFormatter]
stringFromDate:[NSDate date]]
withValue:[BSG_RFC3339DateTool stringFromDate:[NSDate date]]
toTabWithName:BSGKeyDeviceState];
if ([self.configuration automaticallyCollectBreadcrumbs]) {
[self sendBreadcrumbForNotification:notif];
Expand Down
20 changes: 16 additions & 4 deletions Source/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSJSONCodec.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,20 @@ int bsg_ksjsoncodec_i_appendEscapedString(
}

// Deal with complicated case (if any)
int result;
for (; src < srcEnd; src++) {

// If we add an escaped control character this may exceed the buffer by up to
// 6 characters: add this chunk now, reset the buffer and carry on
if (dst + 6 > workBuffer + BSG_KSJSONCODEC_WorkBufferSize) {
size_t encLength = (size_t)(dst - workBuffer);
unlikely_if((result = addJSONData(context, dst - encLength, encLength)) !=
BSG_KSJSON_OK) {
return result;
}
dst = workBuffer;
}

switch (*src) {
case '\\':
case '\"':
Expand Down Expand Up @@ -175,8 +188,7 @@ int bsg_ksjsoncodec_i_appendEscapedString(
}
}
size_t encLength = (size_t)(dst - workBuffer);
dst -= encLength;
return addJSONData(context, dst, encLength);
return addJSONData(context, dst - encLength, encLength);
}

/** Escape a string for use with JSON and send to data handler.
Expand All @@ -198,8 +210,8 @@ int bsg_ksjsoncodec_i_addEscapedString(BSG_KSJSONEncodeContext *const context,
size_t offset = 0;
while (offset < length) {
size_t toAdd = length - offset;
unlikely_if(toAdd > BSG_KSJSONCODEC_WorkBufferSize / 2) {
toAdd = BSG_KSJSONCODEC_WorkBufferSize / 2;
unlikely_if(toAdd > BSG_KSJSONCODEC_WorkBufferSize) {
toAdd = BSG_KSJSONCODEC_WorkBufferSize;
}
result = bsg_ksjsoncodec_i_appendEscapedString(context, string + offset,
toAdd);
Expand Down
Loading

0 comments on commit c64b617

Please sign in to comment.