Permalink
Browse files

Fix Content-Type header checking of React/RCTJavascriptLoader.mm #15791

Summary:
To fix this issue: #15791
Closes #15792

Differential Revision: D5813101

Pulled By: shergin

fbshipit-source-id: fd3eb6f1d9ccdeb5373d1ba2b2df173ff7a8e986
  • Loading branch information...
justinr1234 authored and facebook-github-bot committed Sep 20, 2017
1 parent 11963d8 commit 3ae45d5cb8b9aaca568227ca00cc304e053bf073
Showing with 5 additions and 4 deletions.
  1. +5 −4 React/Base/RCTJavaScriptLoader.mm
@@ -284,16 +284,17 @@ static void attemptAsynchronousLoadOfBundleAtURL(NSURL *scriptURL, RCTSourceLoad
// Validate that the packager actually returned javascript.
NSString *contentType = headers[@"Content-Type"];
if (![contentType isEqualToString:@"application/javascript"] &&
![contentType isEqualToString:@"text/javascript"]) {
NSString *description = [NSString stringWithFormat:@"Expected Content-Type to be 'application/javascript' or 'text/javascript', but got '%@'.", contentType];
NSString *mimeType = [[contentType componentsSeparatedByString:@";"] firstObject];
if (![mimeType isEqualToString:@"application/javascript"] &&
![mimeType isEqualToString:@"text/javascript"]) {
NSString *description = [NSString stringWithFormat:@"Expected MIME-Type to be 'application/javascript' or 'text/javascript', but got '%@'.", mimeType];
error = [NSError errorWithDomain:@"JSServer"
code:NSURLErrorCannotParseResponse
userInfo:@{
NSLocalizedDescriptionKey: description,
@"headers": headers,
@"data": data
}];
}];
onComplete(error, nil);
return;
}

0 comments on commit 3ae45d5

Please sign in to comment.