mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
850e550422
commit
2be409ff55
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user