Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5097aa0

Browse files
committedNov 18, 2021
Verify that the parameter to +[NSURLComponents initWithURL:resolvingAgainstBaseURL:] is not nil
1 parent 2f8866f commit 5097aa0

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed
 

‎BugsnagNetworkRequestPlugin/BugsnagNetworkRequestPlugin.xcodeproj/project.pbxproj

+14-14
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@
757757
buildSettings = {
758758
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
759759
CODE_SIGN_STYLE = Automatic;
760-
DEVELOPMENT_TEAM = 372ZUL2ZB7;
760+
DEVELOPMENT_TEAM = "";
761761
INFOPLIST_FILE = "../Tests/TestHost-iOS/Info.plist";
762762
LD_RUNPATH_SEARCH_PATHS = (
763763
"$(inherited)",
@@ -774,7 +774,7 @@
774774
buildSettings = {
775775
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
776776
CODE_SIGN_STYLE = Automatic;
777-
DEVELOPMENT_TEAM = 372ZUL2ZB7;
777+
DEVELOPMENT_TEAM = "";
778778
INFOPLIST_FILE = "../Tests/TestHost-iOS/Info.plist";
779779
LD_RUNPATH_SEARCH_PATHS = (
780780
"$(inherited)",
@@ -1007,7 +1007,7 @@
10071007
buildSettings = {
10081008
CODE_SIGN_STYLE = Automatic;
10091009
DEFINES_MODULE = YES;
1010-
DEVELOPMENT_TEAM = 372ZUL2ZB7;
1010+
DEVELOPMENT_TEAM = "";
10111011
DYLIB_COMPATIBILITY_VERSION = 1;
10121012
DYLIB_CURRENT_VERSION = 1;
10131013
DYLIB_INSTALL_NAME_BASE = "@rpath";
@@ -1031,7 +1031,7 @@
10311031
buildSettings = {
10321032
CODE_SIGN_STYLE = Automatic;
10331033
DEFINES_MODULE = YES;
1034-
DEVELOPMENT_TEAM = 372ZUL2ZB7;
1034+
DEVELOPMENT_TEAM = "";
10351035
DYLIB_COMPATIBILITY_VERSION = 1;
10361036
DYLIB_CURRENT_VERSION = 1;
10371037
DYLIB_INSTALL_NAME_BASE = "@rpath";
@@ -1054,7 +1054,7 @@
10541054
isa = XCBuildConfiguration;
10551055
buildSettings = {
10561056
CODE_SIGN_STYLE = Automatic;
1057-
DEVELOPMENT_TEAM = 372ZUL2ZB7;
1057+
DEVELOPMENT_TEAM = "";
10581058
GCC_WARN_PEDANTIC = NO;
10591059
GCC_WARN_UNUSED_PARAMETER = NO;
10601060
INFOPLIST_FILE = BugsnagNetworkRequestPluginTests/Info.plist;
@@ -1074,7 +1074,7 @@
10741074
isa = XCBuildConfiguration;
10751075
buildSettings = {
10761076
CODE_SIGN_STYLE = Automatic;
1077-
DEVELOPMENT_TEAM = 372ZUL2ZB7;
1077+
DEVELOPMENT_TEAM = "";
10781078
GCC_WARN_PEDANTIC = NO;
10791079
GCC_WARN_UNUSED_PARAMETER = NO;
10801080
INFOPLIST_FILE = BugsnagNetworkRequestPluginTests/Info.plist;
@@ -1096,7 +1096,7 @@
10961096
CODE_SIGN_STYLE = Automatic;
10971097
COMBINE_HIDPI_IMAGES = YES;
10981098
DEFINES_MODULE = YES;
1099-
DEVELOPMENT_TEAM = 372ZUL2ZB7;
1099+
DEVELOPMENT_TEAM = "";
11001100
DYLIB_COMPATIBILITY_VERSION = 1;
11011101
DYLIB_CURRENT_VERSION = 1;
11021102
DYLIB_INSTALL_NAME_BASE = "@rpath";
@@ -1121,7 +1121,7 @@
11211121
CODE_SIGN_STYLE = Automatic;
11221122
COMBINE_HIDPI_IMAGES = YES;
11231123
DEFINES_MODULE = YES;
1124-
DEVELOPMENT_TEAM = 372ZUL2ZB7;
1124+
DEVELOPMENT_TEAM = "";
11251125
DYLIB_COMPATIBILITY_VERSION = 1;
11261126
DYLIB_CURRENT_VERSION = 1;
11271127
DYLIB_INSTALL_NAME_BASE = "@rpath";
@@ -1145,7 +1145,7 @@
11451145
buildSettings = {
11461146
CODE_SIGN_STYLE = Automatic;
11471147
COMBINE_HIDPI_IMAGES = YES;
1148-
DEVELOPMENT_TEAM = 372ZUL2ZB7;
1148+
DEVELOPMENT_TEAM = "";
11491149
GCC_WARN_PEDANTIC = NO;
11501150
GCC_WARN_UNUSED_PARAMETER = NO;
11511151
INFOPLIST_FILE = BugsnagNetworkRequestPluginTests/Info.plist;
@@ -1166,7 +1166,7 @@
11661166
buildSettings = {
11671167
CODE_SIGN_STYLE = Automatic;
11681168
COMBINE_HIDPI_IMAGES = YES;
1169-
DEVELOPMENT_TEAM = 372ZUL2ZB7;
1169+
DEVELOPMENT_TEAM = "";
11701170
GCC_WARN_PEDANTIC = NO;
11711171
GCC_WARN_UNUSED_PARAMETER = NO;
11721172
INFOPLIST_FILE = BugsnagNetworkRequestPluginTests/Info.plist;
@@ -1187,7 +1187,7 @@
11871187
buildSettings = {
11881188
CODE_SIGN_STYLE = Automatic;
11891189
DEFINES_MODULE = YES;
1190-
DEVELOPMENT_TEAM = 372ZUL2ZB7;
1190+
DEVELOPMENT_TEAM = "";
11911191
DYLIB_COMPATIBILITY_VERSION = 1;
11921192
DYLIB_CURRENT_VERSION = 1;
11931193
DYLIB_INSTALL_NAME_BASE = "@rpath";
@@ -1212,7 +1212,7 @@
12121212
buildSettings = {
12131213
CODE_SIGN_STYLE = Automatic;
12141214
DEFINES_MODULE = YES;
1215-
DEVELOPMENT_TEAM = 372ZUL2ZB7;
1215+
DEVELOPMENT_TEAM = "";
12161216
DYLIB_COMPATIBILITY_VERSION = 1;
12171217
DYLIB_CURRENT_VERSION = 1;
12181218
DYLIB_INSTALL_NAME_BASE = "@rpath";
@@ -1236,7 +1236,7 @@
12361236
isa = XCBuildConfiguration;
12371237
buildSettings = {
12381238
CODE_SIGN_STYLE = Automatic;
1239-
DEVELOPMENT_TEAM = 372ZUL2ZB7;
1239+
DEVELOPMENT_TEAM = "";
12401240
GCC_WARN_PEDANTIC = NO;
12411241
GCC_WARN_UNUSED_PARAMETER = NO;
12421242
INFOPLIST_FILE = BugsnagNetworkRequestPluginTests/Info.plist;
@@ -1257,7 +1257,7 @@
12571257
isa = XCBuildConfiguration;
12581258
buildSettings = {
12591259
CODE_SIGN_STYLE = Automatic;
1260-
DEVELOPMENT_TEAM = 372ZUL2ZB7;
1260+
DEVELOPMENT_TEAM = "";
12611261
GCC_WARN_PEDANTIC = NO;
12621262
GCC_WARN_UNUSED_PARAMETER = NO;
12631263
INFOPLIST_FILE = BugsnagNetworkRequestPluginTests/Info.plist;

‎BugsnagNetworkRequestPlugin/BugsnagNetworkRequestPlugin/BSGURLSessionTracingDelegate.m

+14-6
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@ + (nonnull NSString *)URLStringWithoutQueryForComponents:(nonnull NSURLComponent
8686
- (void)URLSession:(__unused NSURLSession *)session task:(NSURLSessionTask *)task didFinishCollectingMetrics:(NSURLSessionTaskMetrics *)metrics
8787
API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0)) {
8888
if (g_sink != nil) {
89-
// Note: Cannot use metrics transaction request because it might have a 0 length HTTP body.
90-
NSURLRequest *req = task.originalRequest;
91-
NSURLComponents *urlComponents = [NSURLComponents componentsWithURL:req.URL resolvingAgainstBaseURL:YES];
9289
// Note: Cannot use metrics transaction response because it will be nil if a custom NSURLProtocol is present.
9390
// Note: If there was an error, task.response will be nil, and the following values will be set accordingly.
9491
NSHTTPURLResponse *httpResp = [task.response isKindOfClass:NSHTTPURLResponse.class] ? (NSHTTPURLResponse *)task.response : nil;
@@ -97,9 +94,20 @@ - (void)URLSession:(__unused NSURLSession *)session task:(NSURLSessionTask *)tas
9794

9895
NSMutableDictionary *metadata = [NSMutableDictionary dictionary];
9996
metadata[@"duration"] = @((unsigned)(metrics.taskInterval.duration * 1000));
100-
metadata[@"method"] = req.HTTPMethod;
101-
metadata[@"url"] = [BSGURLSessionTracingDelegate URLStringWithoutQueryForComponents:urlComponents];
102-
metadata[@"urlParams"] = [BSGURLSessionTracingDelegate urlParamsForQueryItems:urlComponents.queryItems];
97+
98+
NSURLRequest *req = task.originalRequest;
99+
if (req == nil) {
100+
req = task.currentRequest;
101+
}
102+
if (req) {
103+
metadata[@"method"] = req.HTTPMethod;
104+
if (req.URL) {
105+
NSURLComponents *urlComponents = [NSURLComponents componentsWithURL:req.URL resolvingAgainstBaseURL:YES];
106+
metadata[@"url"] = [BSGURLSessionTracingDelegate URLStringWithoutQueryForComponents:urlComponents];
107+
metadata[@"urlParams"] = [BSGURLSessionTracingDelegate urlParamsForQueryItems:urlComponents.queryItems];
108+
}
109+
}
110+
103111
if (task.countOfBytesSent) {
104112
metadata[@"requestContentLength"] = @(task.countOfBytesSent);
105113
} else if (req.HTTPBody) {

0 commit comments

Comments
 (0)
Please sign in to comment.