Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove "/" from crash report file name #3005

Merged
merged 8 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ This change has no impact on grouping of the issues in Sentry.
### Fixes

- Propagate span when copying scope (#2952)
- Remove "/" from crash report file name (#3005)

## 8.6.0

Expand Down
13 changes: 11 additions & 2 deletions Sources/SentryCrash/Recording/SentryCrash.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,19 @@
static NSString *
getBundleName(void)
{
NSString *bundleName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
static NSString *bundleName = nil;

if (bundleName == nil) {
bundleName = @"Unknown";
#if TEST
bundleName = @"Sentry/Test";
brustolin marked this conversation as resolved.
Show resolved Hide resolved
#else
bundleName =
[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"] ?: @"Unknown";
#endif
brustolin marked this conversation as resolved.
Show resolved Hide resolved
// bundleName is only used for file name, therefore '/' is not allowed.
bundleName = [bundleName stringByReplacingOccurrencesOfString:@"/" withString:@"-"];
}

return bundleName;
}

Expand Down
10 changes: 10 additions & 0 deletions Tests/SentryTests/SentryCrash/SentryCrashTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ @interface SentryCrashTests : FileBasedTestCase
@end

@interface SentryCrash (private)

@property (nonatomic, readwrite, retain) NSString *bundleName;

- (NSArray *)getAttachmentPaths:(int64_t)reportID;

@end

@implementation SentryCrashTests
Expand Down Expand Up @@ -43,6 +47,12 @@ - (void)test_getScreenshots_TwoFiles
XCTAssertEqual(files.count, 2);
}

- (void)test_cleanBundleName
{
SentryCrash *sentryCrash = [[SentryCrash alloc] init];
XCTAssertEqualObjects(sentryCrash.bundleName, @"Sentry-Test");
}

- (void)test_getScreenshots_NoFiles
{
[self initReport:12 withScreenshots:0];
Expand Down