cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject cordova-plugin-whitelist git commit: CB-9337 - enable use of <access> tags for native code network requests
Date Wed, 08 Jul 2015 22:48:06 GMT
Repository: cordova-plugin-whitelist
Updated Branches:
  refs/heads/master b70bf9b3d -> b2143d928


CB-9337 - enable use of <access> tags for native code network requests


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

Branch: refs/heads/master
Commit: b2143d928a84f62531da3887df35bc3ce480ebdc
Parents: b70bf9b
Author: Shazron Abdullah <shazron@gmail.com>
Authored: Wed Jul 8 15:47:53 2015 -0700
Committer: Shazron Abdullah <shazron@gmail.com>
Committed: Wed Jul 8 15:47:53 2015 -0700

----------------------------------------------------------------------
 plugin.xml                             |   6 +-
 src/ios/CDVNavigationWhitelistPlugin.h |  29 --------
 src/ios/CDVNavigationWhitelistPlugin.m |  89 -----------------------
 src/ios/CDVWhitelistPlugin.h           |  30 ++++++++
 src/ios/CDVWhitelistPlugin.m           | 105 ++++++++++++++++++++++++++++
 5 files changed, 138 insertions(+), 121 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-whitelist/blob/b2143d92/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 29f87e0..a6aec21 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -49,12 +49,12 @@
     <platform name="ios">
         <config-file target="config.xml" parent="/*">
             <feature name="Whitelist">
-                <param name="ios-package" value="CDVNavigationWhitelistPlugin" /> 
+                <param name="ios-package" value="CDVWhitelistPlugin" /> 
                 <param name="onload" value="true" />
             </feature>
         </config-file>
-        <header-file src="src/ios/CDVNavigationWhitelistPlugin.h"  />
-        <source-file src="src/ios/CDVNavigationWhitelistPlugin.m" />
+        <header-file src="src/ios/CDVWhitelistPlugin.h"  />
+        <source-file src="src/ios/CDVWhitelistPlugin.m" />
 
         <js-module src="whitelist.js" name="whitelist">
             <runs />

http://git-wip-us.apache.org/repos/asf/cordova-plugin-whitelist/blob/b2143d92/src/ios/CDVNavigationWhitelistPlugin.h
----------------------------------------------------------------------
diff --git a/src/ios/CDVNavigationWhitelistPlugin.h b/src/ios/CDVNavigationWhitelistPlugin.h
deleted file mode 100644
index c1c1301..0000000
--- a/src/ios/CDVNavigationWhitelistPlugin.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements.  See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership.  The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License.  You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied.  See the License for the
- specific language governing permissions and limitations
- under the License.
- */
-
-#import <UIKit/UIKit.h>
-#import <Cordova/CDVPlugin.h>
-#import <Cordova/CDVWhitelist.h>
-#import <Cordova/CDVURLRequestFilter.h>
-
-@interface CDVNavigationWhitelistPlugin : CDVPlugin <CDVURLRequestFilter>{}
-
-@property (nonatomic, readonly, strong) CDVWhitelist* whitelist; // readonly for public
-
-@end

http://git-wip-us.apache.org/repos/asf/cordova-plugin-whitelist/blob/b2143d92/src/ios/CDVNavigationWhitelistPlugin.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVNavigationWhitelistPlugin.m b/src/ios/CDVNavigationWhitelistPlugin.m
deleted file mode 100644
index 11525f2..0000000
--- a/src/ios/CDVNavigationWhitelistPlugin.m
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements.  See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership.  The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License.  You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied.  See the License for the
- specific language governing permissions and limitations
- under the License.
- */
-
-#import "CDVNavigationWhitelistPlugin.h"
-#import <Cordova/CDVViewController.h>
-
-#pragma mark CDVNavigationWhitelistConfigParser
-
-@interface CDVNavigationWhitelistConfigParser : NSObject <NSXMLParserDelegate> {}
-
-@property (nonatomic, strong) NSMutableArray* whitelistHosts;
-
-@end
-
-@implementation CDVNavigationWhitelistConfigParser
-
-@synthesize whitelistHosts;
-
-- (id)init
-{
-    self = [super init];
-    if (self != nil) {
-        self.whitelistHosts = [[NSMutableArray alloc] initWithCapacity:30];
-        [self.whitelistHosts addObject:@"file:///*"];
-        [self.whitelistHosts addObject:@"content:///*"];
-        [self.whitelistHosts addObject:@"data:///*"];
-    }
-    return self;
-}
-
-- (void)parser:(NSXMLParser*)parser didStartElement:(NSString*)elementName namespaceURI:(NSString*)namespaceURI
qualifiedName:(NSString*)qualifiedName attributes:(NSDictionary*)attributeDict
-{
-    if ([elementName isEqualToString:@"allow-navigation"]) {
-        [whitelistHosts addObject:attributeDict[@"href"]];
-    }
-}
-
-- (void)parser:(NSXMLParser*)parser didEndElement:(NSString*)elementName namespaceURI:(NSString*)namespaceURI
qualifiedName:(NSString*)qualifiedName
-{
-}
-
-- (void)parser:(NSXMLParser*)parser parseErrorOccurred:(NSError*)parseError
-{
-    NSAssert(NO, @"config.xml parse error line %ld col %ld", (long)[parser lineNumber], (long)[parser
columnNumber]);
-}
-
-
-@end
-
-#pragma mark CDVNavigationWhitelistPlugin
-
-@interface CDVNavigationWhitelistPlugin () {}
-@property (nonatomic, strong) CDVWhitelist* whitelist;
-@end
-
-@implementation CDVNavigationWhitelistPlugin
-
-@synthesize whitelist;
-
-- (void)setViewController:(UIViewController *)viewController
-{
-    if ([viewController isKindOfClass:[CDVViewController class]]) {
-        CDVNavigationWhitelistConfigParser *whitelistConfigParser = [[CDVNavigationWhitelistConfigParser
alloc] init];
-        [(CDVViewController *)viewController parseSettingsWithParser:whitelistConfigParser];
-        self.whitelist = [[CDVWhitelist alloc] initWithArray:whitelistConfigParser.whitelistHosts];
-    }
-}
-
-- (BOOL)shouldAllowNavigationToURL:(NSURL *)url
-{
-    return [self.whitelist URLIsAllowed:url];
-}
-@end

http://git-wip-us.apache.org/repos/asf/cordova-plugin-whitelist/blob/b2143d92/src/ios/CDVWhitelistPlugin.h
----------------------------------------------------------------------
diff --git a/src/ios/CDVWhitelistPlugin.h b/src/ios/CDVWhitelistPlugin.h
new file mode 100644
index 0000000..b91409c
--- /dev/null
+++ b/src/ios/CDVWhitelistPlugin.h
@@ -0,0 +1,30 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+#import <UIKit/UIKit.h>
+#import <Cordova/CDVPlugin.h>
+#import <Cordova/CDVWhitelist.h>
+#import <Cordova/CDVURLRequestFilter.h>
+
+@interface CDVWhitelistPlugin : CDVPlugin <CDVURLRequestFilter>{}
+
+@property (nonatomic, readonly, strong) CDVWhitelist* navigationWhitelist; // readonly for
public
+@property (nonatomic, readonly, strong) CDVWhitelist* accessWhitelist; // readonly for public
+
+@end

http://git-wip-us.apache.org/repos/asf/cordova-plugin-whitelist/blob/b2143d92/src/ios/CDVWhitelistPlugin.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVWhitelistPlugin.m b/src/ios/CDVWhitelistPlugin.m
new file mode 100644
index 0000000..7785879
--- /dev/null
+++ b/src/ios/CDVWhitelistPlugin.m
@@ -0,0 +1,105 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+#import "CDVWhitelistPlugin.h"
+#import <Cordova/CDVViewController.h>
+
+#pragma mark CDVWhitelistConfigParser
+
+@interface CDVWhitelistConfigParser : NSObject <NSXMLParserDelegate> {}
+
+@property (nonatomic, strong) NSMutableArray* navigationWhitelistHosts;
+@property (nonatomic, strong) NSMutableArray* accessWhitelistHosts;
+
+@end
+
+@implementation CDVWhitelistConfigParser
+
+@synthesize navigationWhitelistHosts, accessWhitelistHosts;
+
+- (id)init
+{
+    self = [super init];
+    if (self != nil) {
+        NSArray* defaultHosts = @[
+                                  @"file:///*",
+                                  @"content:///*",
+                                  @"data:///*"
+                                  ];
+
+        self.navigationWhitelistHosts = [[NSMutableArray alloc] initWithArray:defaultHosts];
+        self.accessWhitelistHosts = [[NSMutableArray alloc] initWithArray:defaultHosts];
+    }
+    return self;
+}
+
+- (void)parser:(NSXMLParser*)parser didStartElement:(NSString*)elementName namespaceURI:(NSString*)namespaceURI
qualifiedName:(NSString*)qualifiedName attributes:(NSDictionary*)attributeDict
+{
+    if ([elementName isEqualToString:@"allow-navigation"]) {
+        [navigationWhitelistHosts addObject:attributeDict[@"href"]];
+    }
+    else if ([elementName isEqualToString:@"access"]) {
+        [accessWhitelistHosts addObject:attributeDict[@"origin"]];
+    }
+}
+
+- (void)parser:(NSXMLParser*)parser didEndElement:(NSString*)elementName namespaceURI:(NSString*)namespaceURI
qualifiedName:(NSString*)qualifiedName
+{
+}
+
+- (void)parser:(NSXMLParser*)parser parseErrorOccurred:(NSError*)parseError
+{
+    NSAssert(NO, @"config.xml parse error line %ld col %ld", (long)[parser lineNumber], (long)[parser
columnNumber]);
+}
+
+
+@end
+
+#pragma mark CDVWhitelistPlugin
+
+@interface CDVWhitelistPlugin () {}
+@property (nonatomic, strong) CDVWhitelist* navigationWhitelist;
+@property (nonatomic, strong) CDVWhitelist* accessWhitelist;
+@end
+
+@implementation CDVWhitelistPlugin
+
+@synthesize navigationWhitelist, accessWhitelist;
+
+- (void)setViewController:(UIViewController *)viewController
+{
+    if ([viewController isKindOfClass:[CDVViewController class]]) {
+        CDVWhitelistConfigParser *whitelistConfigParser = [[CDVWhitelistConfigParser alloc]
init];
+        [(CDVViewController *)viewController parseSettingsWithParser:whitelistConfigParser];
+        self.navigationWhitelist = [[CDVWhitelist alloc] initWithArray:whitelistConfigParser.navigationWhitelistHosts];
+        self.accessWhitelist = [[CDVWhitelist alloc] initWithArray:whitelistConfigParser.accessWhitelistHosts];
+    }
+}
+
+- (BOOL)shouldAllowNavigationToURL:(NSURL *)url
+{
+    return [self.navigationWhitelist URLIsAllowed:url];
+}
+
+- (BOOL)shouldAllowRequestForURL:(NSURL *)url
+{
+    return [self.accessWhitelist URLIsAllowed:url];
+}
+
+@end


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


Mime
View raw message