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 IOS crash in Network Plugin due to incorrect processing of data U… #978

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ - (void)didObserveRequest:(SKRequestInfo*)request {
}

- (void)didObserveResponse:(SKResponseInfo*)response {
// Only track HTTP(S) calls, data URLs cannot be casted to NSHTTPURLResponse
if (![response.response isKindOfClass:[NSHTTPURLResponse class]]) {
return;
}

NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)response.response;

NSMutableArray<NSDictionary<NSString*, id>*>* headers = [NSMutableArray new];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ - (instancetype)initWithIndentifier:(int64_t)identifier
}

+ (BOOL)shouldStripReponseBodyWithResponse:(NSURLResponse*)response {
// Only HTTP(S) responses have Content-Type headers
if (![response isKindOfClass:[NSHTTPURLResponse class]]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering it this shouldn't return YES instead, given that this method returns if the response data should be stripped from the network request details, which is the case for large binary data as images, videos and zips. I can imagine we don't want to send the details fo data: urls to Flipper either? (see also line 50)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. I updated this PR.

return YES;
}

NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)response;
NSString* contentType = httpResponse.allHeaderFields[@"content-type"];
if (!contentType) {
Expand Down