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/15 01:09:20 UTC

ios commit: CB-10171 - WebKit Error after migration to iOS@4.0.0

Repository: cordova-ios
Updated Branches:
  refs/heads/master fc883da84 -> 10cdc418d


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/10cdc418
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/10cdc418
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/10cdc418

Branch: refs/heads/master
Commit: 10cdc418de6f808db1fbc5469492d2906ba1ed0b
Parents: fc883da
Author: Shazron Abdullah <sh...@apache.org>
Authored: Mon Dec 14 16:09:45 2015 -0800
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Mon Dec 14 16:09:45 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/10cdc418/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/10cdc418/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