You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2015/12/16 02:07:12 UTC
[3/6] ios commit: CB-10171 - WebKit Error after migration to iOS@4.0.0
CB-10171 - WebKit Error after migration to iOS@4.0.0
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/444851b9
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/444851b9
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/444851b9
Branch: refs/heads/4.0.x
Commit: 444851b9c76139e61ae00053d4f9b970569e4b4d
Parents: 8a187bf
Author: Shazron Abdullah <sh...@apache.org>
Authored: Mon Dec 14 16:09:45 2015 -0800
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Tue Dec 15 16:59:51 2015 -0800
----------------------------------------------------------------------
CordovaLib/Classes/Public/CDVWhitelist.m | 2 +-
tests/CordovaLibTests/CDVWhitelistTests.m | 25 ++++++++++++++++++-------
2 files changed, 19 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/444851b9/CordovaLib/Classes/Public/CDVWhitelist.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/Public/CDVWhitelist.m b/CordovaLib/Classes/Public/CDVWhitelist.m
index af0a564..552ea95 100644
--- a/CordovaLib/Classes/Public/CDVWhitelist.m
+++ b/CordovaLib/Classes/Public/CDVWhitelist.m
@@ -88,7 +88,7 @@ NSString* const kCDVDefaultSchemeName = @"cdv-default-scheme";
- (bool)matches:(NSURL*)url
{
return (_scheme == nil || [_scheme numberOfMatchesInString:[url scheme] options:NSMatchingAnchored range:NSMakeRange(0, [[url scheme] length])]) &&
- (_host == nil || [_host numberOfMatchesInString:[url host] options:NSMatchingAnchored range:NSMakeRange(0, [[url host] length])]) &&
+ (_host == nil || ([url host] != nil && [_host numberOfMatchesInString:[url host] options:NSMatchingAnchored range:NSMakeRange(0, [[url host] length])])) &&
(_port == nil || [[url port] isEqualToNumber:_port]) &&
(_path == nil || [_path numberOfMatchesInString:[url path] options:NSMatchingAnchored range:NSMakeRange(0, [[url path] length])])
;
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/444851b9/tests/CordovaLibTests/CDVWhitelistTests.m
----------------------------------------------------------------------
diff --git a/tests/CordovaLibTests/CDVWhitelistTests.m b/tests/CordovaLibTests/CDVWhitelistTests.m
index 846658d..5f979c0 100644
--- a/tests/CordovaLibTests/CDVWhitelistTests.m
+++ b/tests/CordovaLibTests/CDVWhitelistTests.m
@@ -241,19 +241,30 @@
XCTAssertTrue([whitelist URLIsAllowed:[NSURL URLWithString:@"https://cordova.apache.org"]]);
}
-- (void)testWildcardPlusScheme
+- (void)testWildcardScheme
{
NSArray* allowedHosts = [NSArray arrayWithObjects:
- @"http://*.apache.org",
+ @"*://*.test.com",
nil];
CDVWhitelist* whitelist = [[CDVWhitelist alloc] initWithArray:allowedHosts];
- XCTAssertTrue([whitelist URLIsAllowed:[NSURL URLWithString:@"http://www.apache.org"]]);
- XCTAssertFalse([whitelist URLIsAllowed:[NSURL URLWithString:@"https://www.google.com"]]);
- XCTAssertFalse([whitelist URLIsAllowed:[NSURL URLWithString:@"ftp://cordova.apache.org"]]);
- XCTAssertTrue([whitelist URLIsAllowed:[NSURL URLWithString:@"http://cordova.apache.org"]]);
- XCTAssertFalse([whitelist URLIsAllowed:[NSURL URLWithString:@"https://cordova.apache.org"]]);
+ XCTAssertFalse([whitelist URLIsAllowed:[NSURL URLWithString:@"http://apache.org"]]);
+ XCTAssertFalse([whitelist URLIsAllowed:[NSURL URLWithString:@"gopher://testtt.com"]]);
+
+ XCTAssertTrue([whitelist URLIsAllowed:[NSURL URLWithString:@"gopher://test.com"]]);
+ XCTAssertTrue([whitelist URLIsAllowed:[NSURL URLWithString:@"http://test.com"]]);
+ XCTAssertTrue([whitelist URLIsAllowed:[NSURL URLWithString:@"http://my.test.com"]]);
+ XCTAssertTrue([whitelist URLIsAllowed:[NSURL URLWithString:@"https://test.com"]]);
+ XCTAssertTrue([whitelist URLIsAllowed:[NSURL URLWithString:@"https://my.test.com"]]);
+
+ XCTAssertTrue([whitelist URLIsAllowed:[NSURL URLWithString:@"http://test.com/my/path"]]);
+ XCTAssertTrue([whitelist URLIsAllowed:[NSURL URLWithString:@"http://my.test.com/my/path"]]);
+ XCTAssertTrue([whitelist URLIsAllowed:[NSURL URLWithString:@"https://test.com/my/path"]]);
+ XCTAssertTrue([whitelist URLIsAllowed:[NSURL URLWithString:@"https://my.test.com/my/path"]]);
+
+ XCTAssertTrue([whitelist URLIsAllowed:[NSURL URLWithString:@"gopher://test.com#foo"]]);
+ XCTAssertFalse([whitelist URLIsAllowed:[NSURL URLWithString:@"#foo"]]);
}
- (void)testCredentials
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org