From 3ae45d5cb8b9aaca568227ca00cc304e053bf073 Mon Sep 17 00:00:00 2001 From: Justin Reynolds Date: Tue, 19 Sep 2017 19:45:52 -0700 Subject: [PATCH] Fix Content-Type header checking of React/RCTJavascriptLoader.mm #15791 Summary: To fix this issue: https://github.com/facebook/react-native/issues/15791 Closes https://github.com/facebook/react-native/pull/15792 Differential Revision: D5813101 Pulled By: shergin fbshipit-source-id: fd3eb6f1d9ccdeb5373d1ba2b2df173ff7a8e986 --- React/Base/RCTJavaScriptLoader.mm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/React/Base/RCTJavaScriptLoader.mm b/React/Base/RCTJavaScriptLoader.mm index 8fd439cb1..09fd6c089 100755 --- a/React/Base/RCTJavaScriptLoader.mm +++ b/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; }