[
https://issues.apache.org/jira/browse/CB-5657?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Andrew Grieve resolved CB-5657.
-------------------------------
Resolution: Fixed
Fix Version/s: 3.4.0
Assignee: Andrew Grieve
Confirmed the bug via web inspector & applied the fix.
Typo'ed the issue in the commit message though :(
http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/7452c68c
> CDVWhitelist.URLIsAllowed crashes app if the URL includes (encoded) spaces
> --------------------------------------------------------------------------
>
> Key: CB-5657
> URL: https://issues.apache.org/jira/browse/CB-5657
> Project: Apache Cordova
> Issue Type: Bug
> Components: iOS
> Affects Versions: 3.1.0
> Reporter: Jamal Johnson
> Assignee: Andrew Grieve
> Fix For: 3.4.0
>
>
> If a url has an encoded (or non-encoded) space in it, the URLIsAllowed method
> crashes the app because
> NSURL URLWithString:[NSString stringWithFormat:@"%@://%@%@",
> kCDVDefaultSchemeName, [url host], [url path]]];
> returns nil which then crashes on this conditional:
> if ([self URLIsAllowed:newUrl logFailure:NO])
> I haven't found where exactly the NSURL's path get's decoded, but maybe it's
> an issue internal to iOS when creating the NSURL from the NSURLRequest in
> CDVURLProtocol.canInitWithRequest? At this point:
> NSURL* theUrl = [theRequest URL];
> theUrl.path does not have the encoding's in the url (ie. %20's are not
> present).
> We have worked around the issue by encoding the path sent to the
> URLWithString method:
> NSURL* newUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@%@",
> kCDVDefaultSchemeName, [url host], [[url path]
> stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
> newUrl is no longer nil and the app doesn't crash
--
This message was sent by Atlassian JIRA
(v6.1.4#6159)