You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ia...@apache.org on 2015/03/26 18:52:34 UTC

[1/9] ios commit: Seperate config.xml parsing logic

Repository: cordova-ios
Updated Branches:
  refs/heads/4.0.x 2e5510ea9 -> a14e08eaa


Seperate config.xml parsing logic

Separates the logic of finding config.xml and feeding its contents to a parser from the task of choosing that parser and using its results


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/9ad1c7c9
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/9ad1c7c9
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/9ad1c7c9

Branch: refs/heads/4.0.x
Commit: 9ad1c7c94179cdeb0d0cf9f0b44bff2b4f07570b
Parents: 2e5510e
Author: Ian Clelland <ic...@chromium.org>
Authored: Thu Oct 23 16:02:59 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Thu Mar 19 10:56:26 2015 -0400

----------------------------------------------------------------------
 CordovaLib/Classes/Public/CDVViewController.h |  2 ++
 CordovaLib/Classes/Public/CDVViewController.m | 10 +++++++---
 2 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9ad1c7c9/CordovaLib/Classes/Public/CDVViewController.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/Public/CDVViewController.h b/CordovaLib/Classes/Public/CDVViewController.h
index e3ead2f..534c649 100644
--- a/CordovaLib/Classes/Public/CDVViewController.h
+++ b/CordovaLib/Classes/Public/CDVViewController.h
@@ -84,4 +84,6 @@
 
 - (BOOL)URLisAllowed:(NSURL*)url;
 
+- (void)parseSettingsWithParser:(NSObject<NSXMLParserDelegate> *)delegate;
+
 @end

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9ad1c7c9/CordovaLib/Classes/Public/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/Public/CDVViewController.m b/CordovaLib/Classes/Public/CDVViewController.m
index bf7e532..a6b7fae 100644
--- a/CordovaLib/Classes/Public/CDVViewController.m
+++ b/CordovaLib/Classes/Public/CDVViewController.m
@@ -163,10 +163,8 @@
     return [self.whitelist URLIsAllowed:url];
 }
 
-- (void)loadSettings
+- (void)parseSettingsWithParser:(NSObject<NSXMLParserDelegate> *)delegate
 {
-    CDVConfigParser* delegate = [[CDVConfigParser alloc] init];
-
     // read from config.xml in the app bundle
     NSString* path = [[NSBundle mainBundle] pathForResource:@"config" ofType:@"xml"];
 
@@ -184,6 +182,12 @@
     }
     [self.configParser setDelegate:((id < NSXMLParserDelegate >)delegate)];
     [self.configParser parse];
+}
+
+- (void)loadSettings
+{
+    CDVConfigParser* delegate = [[CDVConfigParser alloc] init];
+    [self parseSettingsWithParser:delegate];
 
     // Get the plugin dictionary, whitelist and settings from the delegate.
     self.pluginsMap = delegate.pluginsDict;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[2/9] ios commit: Add hooks for whitelist plugins

Posted by ia...@apache.org.
Add hooks for whitelist plugins

This allows plugins to implement two methods:
- (BOOL)shouldAllowRequestForURL:(NSURL *)url
- (BOOL)shouldAllowNavigationToURL:(NSURL *)url
- (BOOL)shouldOpenExternalURL:(NSURL *)url


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/c52e7ecf
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/c52e7ecf
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/c52e7ecf

Branch: refs/heads/4.0.x
Commit: c52e7ecf687c7fb310f696fdb81ec56122f732c8
Parents: 9ad1c7c
Author: Ian Clelland <ic...@chromium.org>
Authored: Fri Oct 24 16:09:07 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Thu Mar 19 11:06:29 2015 -0400

----------------------------------------------------------------------
 CordovaLib/Classes/Public/CDVViewController.h |  3 +
 CordovaLib/Classes/Public/CDVViewController.m | 72 ++++++++++++++++++++++
 2 files changed, 75 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/c52e7ecf/CordovaLib/Classes/Public/CDVViewController.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/Public/CDVViewController.h b/CordovaLib/Classes/Public/CDVViewController.h
index 534c649..693b1e8 100644
--- a/CordovaLib/Classes/Public/CDVViewController.h
+++ b/CordovaLib/Classes/Public/CDVViewController.h
@@ -83,6 +83,9 @@
 - (void)registerPlugin:(CDVPlugin*)plugin withPluginName:(NSString*)pluginName;
 
 - (BOOL)URLisAllowed:(NSURL*)url;
+- (BOOL)shouldAllowRequestForURL:(NSURL *)url;
+- (BOOL)shouldAllowNavigationToURL:(NSURL *)url;
+- (BOOL)shouldOpenExternalURL:(NSURL *)url;
 
 - (void)parseSettingsWithParser:(NSObject<NSXMLParserDelegate> *)delegate;
 

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/c52e7ecf/CordovaLib/Classes/Public/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/Public/CDVViewController.m b/CordovaLib/Classes/Public/CDVViewController.m
index a6b7fae..aeade66 100644
--- a/CordovaLib/Classes/Public/CDVViewController.m
+++ b/CordovaLib/Classes/Public/CDVViewController.m
@@ -684,6 +684,78 @@
     return YES;
 }
 
+#pragma mark Network Policy Plugin (Whitelist) hooks
+
+- (BOOL)shouldAllowRequestForURL:(NSURL *)url
+{
+    BOOL anyPluginsResponded = NO;
+    BOOL shouldAllowRequest = NO;
+    for (NSString* pluginName in pluginObjects) {
+        CDVPlugin* plugin = [pluginObjects objectForKey:pluginName];
+        SEL selector = NSSelectorFromString(@"shouldAllowRequestForURL:");
+        if ([plugin respondsToSelector:selector]) {
+            anyPluginsResponded = YES;
+            shouldAllowRequest = ((BOOL (*)(id, SEL, id))objc_msgSend)(plugin, selector, url);
+            if (shouldAllowRequest == NO) {
+                break;
+            }
+        }
+    }
+    if (anyPluginsResponded) {
+        return shouldAllowRequest;
+    }
+
+    /* Default Policy */
+    return NO;
+}
+
+
+- (BOOL)shouldAllowNavigationToURL:(NSURL *)url
+{
+    BOOL anyPluginsResponded = NO;
+    BOOL shouldAllowNavigation = NO;
+    for (NSString* pluginName in pluginObjects) {
+        CDVPlugin* plugin = [pluginObjects objectForKey:pluginName];
+        SEL selector = NSSelectorFromString(@"shouldAllowNavigationToURL:");
+        if ([plugin respondsToSelector:selector]) {
+            anyPluginsResponded = YES;
+            shouldAllowNavigation = ((BOOL (*)(id, SEL, id))objc_msgSend)(plugin, selector, url);
+            if (shouldAllowNavigation == NO) {
+                break;
+            }
+        }
+    }
+    if (anyPluginsResponded) {
+        return shouldAllowNavigation;
+    }
+
+    /* Default Policy */
+    return NO;
+}
+
+- (BOOL)shouldOpenExternalURL:(NSURL *)url
+{
+    BOOL anyPluginsResponded = NO;
+    BOOL shouldOpenExternalURL = NO;
+    for (NSString* pluginName in pluginObjects) {
+        CDVPlugin* plugin = [pluginObjects objectForKey:pluginName];
+        SEL selector = NSSelectorFromString(@"shouldOpenExternalURL:");
+        if ([plugin respondsToSelector:selector]) {
+            anyPluginsResponded = YES;
+            shouldOpenExternalURL = ((BOOL (*)(id, SEL, id))objc_msgSend)(plugin, selector, url);
+            if (shouldOpenExternalURL == NO) {
+                break;
+            }
+        }
+    }
+    if (anyPluginsResponded) {
+        return shouldOpenExternalURL;
+    }
+
+    /* Default policy */
+    return NO;
+}
+
 #pragma mark GapHelpers
 
 - (void)javascriptAlert:(NSString*)text


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[9/9] ios commit: Merge branch 'unplug-whitelist' into 4.0.x

Posted by ia...@apache.org.
Merge branch 'unplug-whitelist' into 4.0.x


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/a14e08ea
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/a14e08ea
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/a14e08ea

Branch: refs/heads/4.0.x
Commit: a14e08eaa95211450f513c64d569d8c333dee4c5
Parents: 2e5510e 1ebb298
Author: Ian Clelland <ic...@chromium.org>
Authored: Thu Mar 26 13:52:08 2015 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Thu Mar 26 13:52:08 2015 -0400

----------------------------------------------------------------------
 .../Classes/Public/CDVCommandDelegateImpl.m     |   3 +-
 CordovaLib/Classes/Public/CDVConfigParser.h     |   1 -
 CordovaLib/Classes/Public/CDVConfigParser.m     |   9 +-
 CordovaLib/Classes/Public/CDVPlugin.h           |  20 +++
 CordovaLib/Classes/Public/CDVURLProtocol.m      |  24 +---
 CordovaLib/Classes/Public/CDVViewController.h   |   9 +-
 CordovaLib/Classes/Public/CDVViewController.m   | 135 ++++++++++++++-----
 7 files changed, 136 insertions(+), 65 deletions(-)
----------------------------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[4/9] ios commit: Defer whitelist decisions to plugins

Posted by ia...@apache.org.
Defer whitelist decisions to plugins


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/1e8ae646
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/1e8ae646
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/1e8ae646

Branch: refs/heads/4.0.x
Commit: 1e8ae6462a5632efc6caecfecc4c8a6d06c069fc
Parents: c52e7ec
Author: Ian Clelland <ic...@chromium.org>
Authored: Mon Oct 27 10:59:40 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Thu Mar 19 11:06:30 2015 -0400

----------------------------------------------------------------------
 .../Classes/Public/CDVCommandDelegateImpl.m     |  3 +-
 CordovaLib/Classes/Public/CDVURLProtocol.m      | 10 ++-
 CordovaLib/Classes/Public/CDVViewController.h   |  2 +-
 CordovaLib/Classes/Public/CDVViewController.m   | 65 ++++++++++----------
 4 files changed, 37 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/1e8ae646/CordovaLib/Classes/Public/CDVCommandDelegateImpl.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/Public/CDVCommandDelegateImpl.m b/CordovaLib/Classes/Public/CDVCommandDelegateImpl.m
index d4df6c3..629d8e8 100644
--- a/CordovaLib/Classes/Public/CDVCommandDelegateImpl.m
+++ b/CordovaLib/Classes/Public/CDVCommandDelegateImpl.m
@@ -175,8 +175,7 @@
 
 - (BOOL)URLIsWhitelisted:(NSURL*)url
 {
-    return ![_viewController.whitelist schemeIsAllowed:[url scheme]] ||
-           [_viewController.whitelist URLIsAllowed:url logFailure:NO];
+    return [_viewController shouldAllowNavigationToURL:url];
 }
 
 - (NSDictionary*)settings

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/1e8ae646/CordovaLib/Classes/Public/CDVURLProtocol.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/Public/CDVURLProtocol.m b/CordovaLib/Classes/Public/CDVURLProtocol.m
index fce5783..a7a38cd 100644
--- a/CordovaLib/Classes/Public/CDVURLProtocol.m
+++ b/CordovaLib/Classes/Public/CDVURLProtocol.m
@@ -131,12 +131,10 @@ static CDVViewController *viewControllerForRequest(NSURLRequest* request)
             // For this reason, we return NO when cmds exist.
             return !hasCmds;
         }
-        // we only care about http and https connections.
-        // CORS takes care of http: trying to access file: URLs.
-        if ([gWhitelist schemeIsAllowed:[theUrl scheme]]) {
-            // if it FAILS the whitelist, we return TRUE, so we can fail the connection later
-            return ![gWhitelist URLIsAllowed:theUrl];
-        }
+        // Returning YES here means that the request will be handled below, by startLoading, which will
+        // override the network layer and return a 401 instead. Returning NO means that the network layer
+        // will perform as ususal, and the request will be proceed.
+        return ![viewController shouldAllowRequestForURL:theUrl];
     }
 
     return NO;

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/1e8ae646/CordovaLib/Classes/Public/CDVViewController.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/Public/CDVViewController.h b/CordovaLib/Classes/Public/CDVViewController.h
index 693b1e8..f654d6c 100644
--- a/CordovaLib/Classes/Public/CDVViewController.h
+++ b/CordovaLib/Classes/Public/CDVViewController.h
@@ -82,7 +82,7 @@
 - (void)registerPlugin:(CDVPlugin*)plugin withClassName:(NSString*)className;
 - (void)registerPlugin:(CDVPlugin*)plugin withPluginName:(NSString*)pluginName;
 
-- (BOOL)URLisAllowed:(NSURL*)url;
+- (BOOL)URLisAllowed:(NSURL*)url __attribute__((deprecated));
 - (BOOL)shouldAllowRequestForURL:(NSURL *)url;
 - (BOOL)shouldAllowNavigationToURL:(NSURL *)url;
 - (BOOL)shouldOpenExternalURL:(NSURL *)url;

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/1e8ae646/CordovaLib/Classes/Public/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/Public/CDVViewController.m b/CordovaLib/Classes/Public/CDVViewController.m
index aeade66..7247200 100644
--- a/CordovaLib/Classes/Public/CDVViewController.m
+++ b/CordovaLib/Classes/Public/CDVViewController.m
@@ -156,11 +156,7 @@
 
 - (BOOL)URLisAllowed:(NSURL*)url
 {
-    if (self.whitelist == nil) {
-        return YES;
-    }
-
-    return [self.whitelist URLIsAllowed:url];
+    return [self shouldAllowNavigationToURL:url];
 }
 
 - (void)parseSettingsWithParser:(NSObject<NSXMLParserDelegate> *)delegate
@@ -629,24 +625,44 @@
     }
 
     /*
-     * If a URL is being loaded that's a file/http/https URL, just load it internally
+     *    If we loaded the HTML from a string, we let the app handle it
      */
-    if ([url isFileURL]) {
+    if (self.loadFromString == YES) {
+        self.loadFromString = NO;
         return YES;
     }
 
     /*
-     *    If we loaded the HTML from a string, we let the app handle it
+     * Handle all other types of urls (tel:, sms:), and requests to load a url in the main webview.
      */
-    else if (self.loadFromString == YES) {
-        self.loadFromString = NO;
+    BOOL shouldAllowNavigation = [self shouldAllowNavigationToURL:url];
+    if (shouldAllowNavigation) {
         return YES;
+    } else {
+        BOOL shouldOpenExternalURL = [self shouldOpenExternalURL:url];
+        if (shouldOpenExternalURL) {
+            if ([[UIApplication sharedApplication] canOpenURL:url]) {
+                [[UIApplication sharedApplication] openURL:url];
+            } else { // handle any custom schemes to plugins
+                [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
+            }
+        }
     }
 
+    return NO;
+}
+
+#pragma mark Network Policy Plugin (Whitelist) hooks
+
+/* This implements the default policy for resource loading and navigation, if there
+ * are no plugins installed which override the whitelist methods.
+ */
+- (BOOL)defaultResourcePolicyForURL:(NSURL *)url
+{
     /*
-     * all tel: scheme urls we let the UIWebview handle it using the default behavior
+     * If a URL is being loaded that's a file/http/https URL, just load it internally
      */
-    else if ([[url scheme] isEqualToString:@"tel"]) {
+    if ([url isFileURL]) {
         return YES;
     }
 
@@ -664,28 +680,9 @@
         return YES;
     }
 
-    /*
-     * Handle all other types of urls (tel:, sms:), and requests to load a url in the main webview.
-     */
-    else {
-        if ([self.whitelist schemeIsAllowed:[url scheme]]) {
-            return [self.whitelist URLIsAllowed:url];
-        } else {
-            if ([[UIApplication sharedApplication] canOpenURL:url]) {
-                [[UIApplication sharedApplication] openURL:url];
-            } else { // handle any custom schemes to plugins
-                [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
-            }
-        }
-
-        return NO;
-    }
-
-    return YES;
+    return NO;
 }
 
-#pragma mark Network Policy Plugin (Whitelist) hooks
-
 - (BOOL)shouldAllowRequestForURL:(NSURL *)url
 {
     BOOL anyPluginsResponded = NO;
@@ -706,7 +703,7 @@
     }
 
     /* Default Policy */
-    return NO;
+    return [self defaultResourcePolicyForURL:url];
 }
 
 
@@ -730,7 +727,7 @@
     }
 
     /* Default Policy */
-    return NO;
+    return [self defaultResourcePolicyForURL:url];
 }
 
 - (BOOL)shouldOpenExternalURL:(NSURL *)url


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[7/9] ios commit: Add deprecation message for [CDVViewController URLIsAllowed]

Posted by ia...@apache.org.
Add deprecation message for [CDVViewController URLIsAllowed]


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/1ebb298f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/1ebb298f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/1ebb298f

Branch: refs/heads/4.0.x
Commit: 1ebb298ffd479468c31ddecf2a8c07b8bdcf1dcd
Parents: d4829c1
Author: Ian Clelland <ic...@chromium.org>
Authored: Wed Nov 12 09:55:45 2014 -0500
Committer: Ian Clelland <ic...@chromium.org>
Committed: Thu Mar 19 11:06:30 2015 -0400

----------------------------------------------------------------------
 CordovaLib/Classes/Public/CDVViewController.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/1ebb298f/CordovaLib/Classes/Public/CDVViewController.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/Public/CDVViewController.h b/CordovaLib/Classes/Public/CDVViewController.h
index 27d4807..0ad1c89 100644
--- a/CordovaLib/Classes/Public/CDVViewController.h
+++ b/CordovaLib/Classes/Public/CDVViewController.h
@@ -80,7 +80,7 @@
 - (void)registerPlugin:(CDVPlugin*)plugin withClassName:(NSString*)className;
 - (void)registerPlugin:(CDVPlugin*)plugin withPluginName:(NSString*)pluginName;
 
-- (BOOL)URLisAllowed:(NSURL*)url __attribute__((deprecated));
+- (BOOL)URLisAllowed:(NSURL*)url __attribute__((deprecated("Scheduled for removal in 5.0. Use shouldAllowRequestForURL, shouldAllowNavigationToURL or shouldOpenExternalURL instead.")));
 - (BOOL)shouldAllowRequestForURL:(NSURL *)url;
 - (BOOL)shouldAllowNavigationToURL:(NSURL *)url;
 - (BOOL)shouldOpenExternalURL:(NSURL *)url;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[8/9] ios commit: Document use of new plugin network policy (whitelist) hooks

Posted by ia...@apache.org.
Document use of new plugin network policy (whitelist) hooks


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/656ae1c0
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/656ae1c0
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/656ae1c0

Branch: refs/heads/4.0.x
Commit: 656ae1c02802cc84bb21e199b8e65085b24b1d50
Parents: 5955096
Author: Ian Clelland <ic...@chromium.org>
Authored: Thu Oct 30 14:12:45 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Thu Mar 19 11:06:30 2015 -0400

----------------------------------------------------------------------
 CordovaLib/Classes/Public/CDVPlugin.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/656ae1c0/CordovaLib/Classes/Public/CDVPlugin.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/Public/CDVPlugin.h b/CordovaLib/Classes/Public/CDVPlugin.h
index 54c8afd..ff4c2f5 100644
--- a/CordovaLib/Classes/Public/CDVPlugin.h
+++ b/CordovaLib/Classes/Public/CDVPlugin.h
@@ -64,6 +64,26 @@ extern NSString* const CDVRemoteNotificationError;
  - (void)didReceiveLocalNotification:(NSNotification *)notification;
  */
 
+ /*
+ // These methods may optionally be implemented. If present, they will be called by CVDViewController when network-policy (whitelist) decisions need to be made.
+
+    This method, if present, will be called by CDVURLProtocol to determine whether to block a request for a web resource. If all plugins which implement this method return true, then the request will be allowed. If any plugin returns false, the request will be blocked. If no plugins implement this method, then the default policy will be followed. (See [CDVViewController defaultResourcePolicyForURL:])
+
+    Note that this method will *not* be called for some resources, such as WebSocket connections, and will not be called by WKWebView at all. Please use CSP headers to handle those situations if needed.
+
+ - (BOOL)shouldAllowRequestForURL:(NSURL *)url
+
+
+    This method, if present, will be called by CDVViewController to determine whether webview navigation to a web page should be allowed. If all plugins which implement this method return true, then the navigation will be allowed. If any plugin returns false, the navigation will be blocked. If no plugins implement this method, then the default policy will be followed. (See [CDVViewController defaultResourcePolicyForURL:])
+
+ - (BOOL)shouldAllowNavigationToURL:(NSURL *)url
+
+
+    This method, if present, will be called by CDVViewController to determine whether a web page which is otherwise blocked should be opened in the system browser. If all plugins which implement this method return true, then the page will be opened. If any plugin returns false, the page will not be opened. If no plugins implement this method, then the default policy will be followed. (See [CDVViewController shouldOpenExternalURL:] and [CDVViewController webView:shouldStartLoadWithRequest:navigationType:])
+
+ - (BOOL)shouldOpenExternalURL:(NSURL *)url
+ */
+
 - (id)appDelegate;
 
 @end


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[6/9] ios commit: Remove whitelist config.xml parsing

Posted by ia...@apache.org.
Remove whitelist config.xml parsing


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/59550961
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/59550961
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/59550961

Branch: refs/heads/4.0.x
Commit: 595509616b0df8dd7856193db86c9bcdefc22a96
Parents: 57939bc
Author: Ian Clelland <ic...@chromium.org>
Authored: Fri Oct 24 16:14:15 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Thu Mar 19 11:06:30 2015 -0400

----------------------------------------------------------------------
 CordovaLib/Classes/Public/CDVConfigParser.h | 1 -
 CordovaLib/Classes/Public/CDVConfigParser.m | 9 +--------
 2 files changed, 1 insertion(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/59550961/CordovaLib/Classes/Public/CDVConfigParser.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/Public/CDVConfigParser.h b/CordovaLib/Classes/Public/CDVConfigParser.h
index 2e06c88..bae3d0f 100644
--- a/CordovaLib/Classes/Public/CDVConfigParser.h
+++ b/CordovaLib/Classes/Public/CDVConfigParser.h
@@ -24,7 +24,6 @@
 
 @property (nonatomic, readonly, strong) NSMutableDictionary* pluginsDict;
 @property (nonatomic, readonly, strong) NSMutableDictionary* settings;
-@property (nonatomic, readonly, strong) NSMutableArray* whitelistHosts;
 @property (nonatomic, readonly, strong) NSMutableArray* startupPluginNames;
 @property (nonatomic, readonly, strong) NSString* startPage;
 

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/59550961/CordovaLib/Classes/Public/CDVConfigParser.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/Public/CDVConfigParser.m b/CordovaLib/Classes/Public/CDVConfigParser.m
index 4b73b60..ab32b4a 100644
--- a/CordovaLib/Classes/Public/CDVConfigParser.m
+++ b/CordovaLib/Classes/Public/CDVConfigParser.m
@@ -23,7 +23,6 @@
 
 @property (nonatomic, readwrite, strong) NSMutableDictionary* pluginsDict;
 @property (nonatomic, readwrite, strong) NSMutableDictionary* settings;
-@property (nonatomic, readwrite, strong) NSMutableArray* whitelistHosts;
 @property (nonatomic, readwrite, strong) NSMutableArray* startupPluginNames;
 @property (nonatomic, readwrite, strong) NSString* startPage;
 
@@ -31,7 +30,7 @@
 
 @implementation CDVConfigParser
 
-@synthesize pluginsDict, settings, whitelistHosts, startPage, startupPluginNames;
+@synthesize pluginsDict, settings, startPage, startupPluginNames;
 
 - (id)init
 {
@@ -39,10 +38,6 @@
     if (self != nil) {
         self.pluginsDict = [[NSMutableDictionary alloc] initWithCapacity:30];
         self.settings = [[NSMutableDictionary alloc] initWithCapacity:30];
-        self.whitelistHosts = [[NSMutableArray alloc] initWithCapacity:30];
-        [self.whitelistHosts addObject:@"file:///*"];
-        [self.whitelistHosts addObject:@"content:///*"];
-        [self.whitelistHosts addObject:@"data:///*"];
         self.startupPluginNames = [[NSMutableArray alloc] initWithCapacity:8];
         featureName = nil;
     }
@@ -66,8 +61,6 @@
         if (paramIsOnload || attribIsOnload) {
             [self.startupPluginNames addObject:featureName];
         }
-    } else if ([elementName isEqualToString:@"access"]) {
-        [whitelistHosts addObject:attributeDict[@"origin"]];
     } else if ([elementName isEqualToString:@"content"]) {
         self.startPage = attributeDict[@"src"];
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[5/9] ios commit: Remove whitelist objects from CDVURLProtocol and CDVViewController classes

Posted by ia...@apache.org.
Remove whitelist objects from CDVURLProtocol and CDVViewController classes


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/57939bcf
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/57939bcf
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/57939bcf

Branch: refs/heads/4.0.x
Commit: 57939bcf8f72c8bd858a6092bf4bcbd3a6d01203
Parents: 1e8ae64
Author: Ian Clelland <ic...@chromium.org>
Authored: Fri Oct 24 16:13:47 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Thu Mar 19 11:06:30 2015 -0400

----------------------------------------------------------------------
 CordovaLib/Classes/Public/CDVURLProtocol.m    | 14 +-------------
 CordovaLib/Classes/Public/CDVViewController.h |  2 --
 CordovaLib/Classes/Public/CDVViewController.m |  4 +---
 3 files changed, 2 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/57939bcf/CordovaLib/Classes/Public/CDVURLProtocol.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/Public/CDVURLProtocol.m b/CordovaLib/Classes/Public/CDVURLProtocol.m
index a7a38cd..c345060 100644
--- a/CordovaLib/Classes/Public/CDVURLProtocol.m
+++ b/CordovaLib/Classes/Public/CDVURLProtocol.m
@@ -23,10 +23,8 @@
 #import <MobileCoreServices/MobileCoreServices.h>
 #import "CDVURLProtocol.h"
 #import "CDVCommandQueue.h"
-#import "CDVWhitelist.h"
 #import "CDVViewController.h"
 
-static CDVWhitelist* gWhitelist = nil;
 // Contains a set of NSNumbers of addresses of controllers. It doesn't store
 // the actual pointer to avoid retaining.
 static NSMutableSet* gRegisteredControllers = nil;
@@ -77,16 +75,6 @@ static CDVViewController *viewControllerForRequest(NSURLRequest* request)
     if (gRegisteredControllers == nil) {
         [NSURLProtocol registerClass:[CDVURLProtocol class]];
         gRegisteredControllers = [[NSMutableSet alloc] initWithCapacity:8];
-        // The whitelist doesn't change, so grab the first one and store it.
-        gWhitelist = viewController.whitelist;
-
-        // Note that we grab the whitelist from the first viewcontroller for now - but this will change
-        // when we allow a registered viewcontroller to have its own whitelist (e.g InAppBrowser)
-        // Differentiating the requests will be through the 'vc' http header below as used for the js->objc bridge.
-        //  The 'vc' value is generated by casting the viewcontroller object to a (long long) value (see CDVViewController::webViewDidFinishLoad)
-        if (gWhitelist == nil) {
-            NSLog(@"WARNING: NO whitelist has been set in CDVURLProtocol.");
-        }
     }
 
     @synchronized(gRegisteredControllers) {
@@ -179,7 +167,7 @@ static CDVViewController *viewControllerForRequest(NSURLRequest* request)
         return;
     }
 
-    NSString* body = [gWhitelist errorStringForURL:url];
+    NSString* body = [NSString stringWithFormat:@"Access not allowed to URL: %@", url];
     [self sendResponseWithResponseCode:401 data:[body dataUsingEncoding:NSASCIIStringEncoding] mimeType:nil];
 }
 

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/57939bcf/CordovaLib/Classes/Public/CDVViewController.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/Public/CDVViewController.h b/CordovaLib/Classes/Public/CDVViewController.h
index f654d6c..27d4807 100644
--- a/CordovaLib/Classes/Public/CDVViewController.h
+++ b/CordovaLib/Classes/Public/CDVViewController.h
@@ -23,7 +23,6 @@
 #import "CDVInvokedUrlCommand.h"
 #import "CDVCommandDelegate.h"
 #import "CDVCommandQueue.h"
-#import "CDVWhitelist.h"
 #import "CDVScreenOrientationDelegate.h"
 #import "CDVPlugin.h"
 #import "CDVWebViewEngineProtocol.h"
@@ -44,7 +43,6 @@
 @property (nonatomic, readonly, strong) NSDictionary* pluginsMap;
 @property (nonatomic, readonly, strong) NSMutableDictionary* settings;
 @property (nonatomic, readonly, strong) NSXMLParser* configParser;
-@property (nonatomic, readonly, strong) CDVWhitelist* whitelist; // readonly for public
 @property (nonatomic, readonly, assign) BOOL loadFromString;
 
 @property (nonatomic, readwrite, copy) NSString* wwwFolderName;

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/57939bcf/CordovaLib/Classes/Public/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/Public/CDVViewController.m b/CordovaLib/Classes/Public/CDVViewController.m
index 7247200..305c63e 100644
--- a/CordovaLib/Classes/Public/CDVViewController.m
+++ b/CordovaLib/Classes/Public/CDVViewController.m
@@ -36,7 +36,6 @@
 
 @property (nonatomic, readwrite, strong) NSXMLParser* configParser;
 @property (nonatomic, readwrite, strong) NSMutableDictionary* settings;
-@property (nonatomic, readwrite, strong) CDVWhitelist* whitelist;
 @property (nonatomic, readwrite, strong) NSMutableDictionary* pluginObjects;
 @property (nonatomic, readwrite, strong) NSMutableArray* startupPluginNames;
 @property (nonatomic, readwrite, strong) NSDictionary* pluginsMap;
@@ -53,7 +52,7 @@
 @implementation CDVViewController
 
 @synthesize supportedOrientations;
-@synthesize pluginObjects, pluginsMap, whitelist, startupPluginNames;
+@synthesize pluginObjects, pluginsMap, startupPluginNames;
 @synthesize configParser, settings, loadFromString;
 @synthesize wwwFolderName, startPage, initialized, openURL, baseUserAgent;
 @synthesize commandDelegate = _commandDelegate;
@@ -188,7 +187,6 @@
     // Get the plugin dictionary, whitelist and settings from the delegate.
     self.pluginsMap = delegate.pluginsDict;
     self.startupPluginNames = delegate.startupPluginNames;
-    self.whitelist = [[CDVWhitelist alloc] initWithArray:delegate.whitelistHosts];
     self.settings = delegate.settings;
 
     // And the start folder/page.


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[3/9] ios commit: Replace explicit boolean comparisons with implicit ones

Posted by ia...@apache.org.
Replace explicit boolean comparisons with implicit ones

(Avoids the "== YES" failing on (BOOL)2 problem)


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/d4829c1b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/d4829c1b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/d4829c1b

Branch: refs/heads/4.0.x
Commit: d4829c1baef9046db63123e437468a01a50c5832
Parents: 656ae1c
Author: Ian Clelland <ic...@chromium.org>
Authored: Thu Oct 30 14:13:17 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Thu Mar 19 11:06:30 2015 -0400

----------------------------------------------------------------------
 CordovaLib/Classes/Public/CDVViewController.m | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/d4829c1b/CordovaLib/Classes/Public/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/Public/CDVViewController.m b/CordovaLib/Classes/Public/CDVViewController.m
index 305c63e..d75df96 100644
--- a/CordovaLib/Classes/Public/CDVViewController.m
+++ b/CordovaLib/Classes/Public/CDVViewController.m
@@ -616,7 +616,7 @@
         CDVPlugin* plugin = [pluginObjects objectForKey:pluginName];
         SEL selector = NSSelectorFromString(@"shouldOverrideLoadWithRequest:navigationType:");
         if ([plugin respondsToSelector:selector]) {
-            if (((BOOL (*)(id, SEL, id, int))objc_msgSend)(plugin, selector, request, navigationType) == YES) {
+            if (((BOOL (*)(id, SEL, id, int))objc_msgSend)(plugin, selector, request, navigationType)) {
                 return NO;
             }
         }
@@ -625,7 +625,7 @@
     /*
      *    If we loaded the HTML from a string, we let the app handle it
      */
-    if (self.loadFromString == YES) {
+    if (self.loadFromString) {
         self.loadFromString = NO;
         return YES;
     }
@@ -691,7 +691,7 @@
         if ([plugin respondsToSelector:selector]) {
             anyPluginsResponded = YES;
             shouldAllowRequest = ((BOOL (*)(id, SEL, id))objc_msgSend)(plugin, selector, url);
-            if (shouldAllowRequest == NO) {
+            if (!shouldAllowRequest) {
                 break;
             }
         }
@@ -715,7 +715,7 @@
         if ([plugin respondsToSelector:selector]) {
             anyPluginsResponded = YES;
             shouldAllowNavigation = ((BOOL (*)(id, SEL, id))objc_msgSend)(plugin, selector, url);
-            if (shouldAllowNavigation == NO) {
+            if (!shouldAllowNavigation) {
                 break;
             }
         }
@@ -738,7 +738,7 @@
         if ([plugin respondsToSelector:selector]) {
             anyPluginsResponded = YES;
             shouldOpenExternalURL = ((BOOL (*)(id, SEL, id))objc_msgSend)(plugin, selector, url);
-            if (shouldOpenExternalURL == NO) {
+            if (!shouldOpenExternalURL) {
                 break;
             }
         }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org