mirror of
https://github.com/status-im/react-native.git
synced 2025-01-10 01:25:39 +00:00
3ac3749ac3
Summary: This is **a critical issue**. The issue arises when incremental networking is enabled from JS by setting `onprogress` or `onload` on an `XMLHttpRequest` object. The results: ![example1](https://cloud.githubusercontent.com/assets/2270433/18829964/5a54ff30-83e7-11e6-9806-97857dce0430.png) ![example2](https://cloud.githubusercontent.com/assets/2270433/18829966/5bf40a66-83e7-11e6-84e6-9e4d76ba4f8b.png) Unicode characters get corrupted seemingly in random. The issue is from the way Unicode character parsing is handled in `RCTNetworking.mm`. When incremental networking is enabled, each chunk of data is decoded and passed to JS: ```objective-c incrementalDataBlock = ^(NSData *data, int64_t progress, int64_t total) { NSString *responseString = [RCTNetworking decodeTextData:data fromResponse:task.response]; if (!responseString) { RCTLogWarn(@"Received data was not a string, or was not a recognised encoding."); return; } NSArray<id> *responseJSON = @[task.requestID, responseString, @(prog Closes https://github.com/facebook/react-native/pull/10110 Reviewed By: yungsters Differential Revision: D4101533 Pulled By: fkgozali fbshipit-source-id: 2674eaf0dd4568889070c6cde5cdf12edc5be521