cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [02/13] ios commit: [CB-3321] Fix bogus "failed whitelist" log messages
Date Mon, 13 May 2013 18:50:23 GMT
[CB-3321] Fix bogus "failed whitelist" log messages


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

Branch: refs/heads/3.0.0
Commit: bb7556d6ac90f3db6c19982cacef0f30d6fd9ff1
Parents: 2f53c3f
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Thu May 2 10:44:39 2013 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Thu May 2 10:44:39 2013 -0400

----------------------------------------------------------------------
 CordovaLib/Classes/CDVWhitelist.h |    1 +
 CordovaLib/Classes/CDVWhitelist.m |   14 ++++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/bb7556d6/CordovaLib/Classes/CDVWhitelist.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVWhitelist.h b/CordovaLib/Classes/CDVWhitelist.h
index e339dd0..9165097 100644
--- a/CordovaLib/Classes/CDVWhitelist.h
+++ b/CordovaLib/Classes/CDVWhitelist.h
@@ -28,6 +28,7 @@ extern NSString* const kCDVDefaultWhitelistRejectionString;
 - (id)initWithArray:(NSArray*)array;
 - (BOOL)schemeIsAllowed:(NSString*)scheme;
 - (BOOL)URLIsAllowed:(NSURL*)url;
+- (BOOL)URLIsAllowed:(NSURL*)url logFailure:(BOOL)logFailure;
 - (NSString*)errorStringForURL:(NSURL*)url;
 
 @end

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/bb7556d6/CordovaLib/Classes/CDVWhitelist.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVWhitelist.m b/CordovaLib/Classes/CDVWhitelist.m
index db7aa32..686a0ed 100644
--- a/CordovaLib/Classes/CDVWhitelist.m
+++ b/CordovaLib/Classes/CDVWhitelist.m
@@ -170,19 +170,27 @@ NSString* const kCDVDefaultSchemeName = @"cdv-default-scheme";
 
 - (BOOL)URLIsAllowed:(NSURL*)url
 {
+    return [self URLIsAllowed:url logFailure:YES];
+}
+
+- (BOOL)URLIsAllowed:(NSURL*)url logFailure:(BOOL)logFailure
+{
     NSString* scheme = [url scheme];
 
     // http[s] and ftp[s] should also validate against the common set in the kCDVDefaultSchemeName
list
     if ([scheme isEqualToString:@"http"] || [scheme isEqualToString:@"https"] || [scheme
isEqualToString:@"ftp"] || [scheme isEqualToString:@"ftps"]) {
         NSURL* newUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@", kCDVDefaultSchemeName,
[url host]]];
         // If it is allowed, we are done.  If not, continue to check for the actual scheme-specific
list
-        if ([self URLIsAllowed:newUrl]) {
+        if ([self URLIsAllowed:newUrl logFailure:NO]) {
             return YES;
         }
     }
 
     // Check that the scheme is supported
     if (![self schemeIsAllowed:scheme]) {
+        if (logFailure) {
+            NSLog(@"%@", [self errorStringForURL:url]);
+        }
         return NO;
     }
 
@@ -210,7 +218,9 @@ NSString* const kCDVDefaultSchemeName = @"cdv-default-scheme";
         }
     }
 
-    NSLog(@"%@", [self errorStringForURL:url]);
+    if (logFailure) {
+        NSLog(@"%@", [self errorStringForURL:url]);
+    }
     // if we got here, the url host is not in the white-list, do nothing
     return NO;
 }


Mime
View raw message