From 2be409ff55b50563a5f123f7823fa7cdb72dbef9 Mon Sep 17 00:00:00 2001 From: Phillip Pan Date: Fri, 15 Sep 2023 14:53:26 -0700 Subject: [PATCH] hot fix for incorrect url parsing Summary: in this diff, we backout D49335986 to fix the issue where we are losing context from decoding an encoded string all at once via `NSURL URLWithString....`. this fixes the category of issues in https://fb.workplace.com/groups/rn.support/posts/25183724564582821. however, this will regress the original issue that this fixed (https://fb.workplace.com/groups/rn.support/posts/25129344753354136), where encoding square brackets in the URI is causing percents to be re-encoded, resulting in a mixed uri with mixed encoding, i.e. `%2522%5B%5D`. we will be fixing this by not serving decoding brackets in our php serializer which was originally be the follow-up fix, since that does not respect the RFC. bypass-github-export-checks Reviewed By: fkgozali Differential Revision: D49336101 fbshipit-source-id: 2012390b237de8a16a5e60e880905cec48584873 --- packages/react-native/React/Base/RCTConvert.m | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/packages/react-native/React/Base/RCTConvert.m b/packages/react-native/React/Base/RCTConvert.m index 04247093fd9..3a7d2b4fc35 100644 --- a/packages/react-native/React/Base/RCTConvert.m +++ b/packages/react-native/React/Base/RCTConvert.m @@ -84,16 +84,7 @@ RCT_CUSTOM_CONVERTER(NSData *, NSData, [json dataUsingEncoding:NSUTF8StringEncod } @try { // NSURL has a history of crashing with bad input, so let's be safe - NSURL *URL = nil; - -#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 170000 - if (@available(iOS 17.0, *)) { - NSString *decodedPercentPath = [path stringByRemovingPercentEncoding]; - URL = [NSURL URLWithString:decodedPercentPath encodingInvalidCharacters:YES]; - } -#endif - - URL = URL ?: [NSURL URLWithString:path]; + NSURL *URL = [NSURL URLWithString:path]; if (URL.scheme) { // Was a well-formed absolute URL return URL; }