Repository: cordova-ios Updated Branches: refs/heads/master 9513bc65b -> 10e17d6d0
CB-10025 - CDVWhiteList can't parse URIs that don't have double slashes after the scheme Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/10e17d6d Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/10e17d6d Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/10e17d6d Branch: refs/heads/master Commit: 10e17d6d0102926c4a88948ea922fc269abe7cf3 Parents: 9513bc6 Author: Shazron Abdullah <[email protected]> Authored: Tue Nov 17 11:10:16 2015 -0800 Committer: Shazron Abdullah <[email protected]> Committed: Tue Nov 17 11:10:16 2015 -0800 ---------------------------------------------------------------------- CordovaLib/Classes/Public/CDVWhitelist.m | 2 +- tests/CordovaLibTests/CDVWhitelistTests.m | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/10e17d6d/CordovaLib/Classes/Public/CDVWhitelist.m ---------------------------------------------------------------------- diff --git a/CordovaLib/Classes/Public/CDVWhitelist.m b/CordovaLib/Classes/Public/CDVWhitelist.m index 35fb225..af0a564 100644 --- a/CordovaLib/Classes/Public/CDVWhitelist.m +++ b/CordovaLib/Classes/Public/CDVWhitelist.m @@ -169,7 +169,7 @@ NSString* const kCDVDefaultSchemeName = @"cdv-default-scheme"; self.whitelist = nil; self.permittedSchemes = nil; } else { // specific access - NSRegularExpression* parts = [NSRegularExpression regularExpressionWithPattern:@"^((\\*|[A-Za-z-]+)://)?(((\\*\\.)?[^*/:]+)|\\*)?(:(\\d+))?(/.*)?" options:0 error:nil]; + NSRegularExpression* parts = [NSRegularExpression regularExpressionWithPattern:@"^((\\*|[A-Za-z-]+):/?/?)?(((\\*\\.)?[^*/:]+)|\\*)?(:(\\d+))?(/.*)?" options:0 error:nil]; NSTextCheckingResult* m = [parts firstMatchInString:origin options:NSMatchingAnchored range:NSMakeRange(0, [origin length])]; if (m != nil) { NSRange r; http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/10e17d6d/tests/CordovaLibTests/CDVWhitelistTests.m ---------------------------------------------------------------------- diff --git a/tests/CordovaLibTests/CDVWhitelistTests.m b/tests/CordovaLibTests/CDVWhitelistTests.m index 5811e72..846658d 100644 --- a/tests/CordovaLibTests/CDVWhitelistTests.m +++ b/tests/CordovaLibTests/CDVWhitelistTests.m @@ -84,6 +84,19 @@ XCTAssertTrue([whitelist URLIsAllowed:[NSURL URLWithString:@"gopher://apache.org"]]); } +- (void)testURISchemesNotFollowedByDoubleSlashes +{ + NSArray* allowedHosts = [NSArray arrayWithObjects: + @"tel:*", + @"sms:*", + nil]; + + CDVWhitelist* whitelist = [[CDVWhitelist alloc] initWithArray:allowedHosts]; + + XCTAssertTrue([whitelist URLIsAllowed:[NSURL URLWithString:@"tel:1234567890"]]); + XCTAssertTrue([whitelist URLIsAllowed:[NSURL URLWithString:@"sms:1234567890"]]); +} + - (void)testCatchallWildcardByProto { NSArray* allowedHosts = [NSArray arrayWithObjects: --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
