Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 405C311B3B for ; Mon, 13 May 2013 19:50:24 +0000 (UTC) Received: (qmail 11436 invoked by uid 500); 13 May 2013 18:50:23 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 11409 invoked by uid 500); 13 May 2013 18:50:23 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 11294 invoked by uid 99); 13 May 2013 18:50:23 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 May 2013 18:50:23 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id E723888FC4B; Mon, 13 May 2013 18:50:22 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: steven@apache.org To: commits@cordova.apache.org Date: Mon, 13 May 2013 18:50:23 -0000 Message-Id: <5e0b6166dd224fb988028a6d34dec329@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [02/13] ios commit: [CB-3321] Fix bogus "failed whitelist" log messages [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 Authored: Thu May 2 10:44:39 2013 -0400 Committer: Andrew Grieve 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; }