Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 8C701200B5A for ; Thu, 4 Aug 2016 14:35:27 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 8B0CF160AAB; Thu, 4 Aug 2016 12:35:27 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D1DB9160A7C for ; Thu, 4 Aug 2016 14:35:26 +0200 (CEST) Received: (qmail 64927 invoked by uid 500); 4 Aug 2016 12:35:26 -0000 Mailing-List: contact dev-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 dev@cordova.apache.org Received: (qmail 64916 invoked by uid 99); 4 Aug 2016 12:35:25 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Aug 2016 12:35:25 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 87D2FE0A7D; Thu, 4 Aug 2016 12:35:25 +0000 (UTC) From: tony-- To: dev@cordova.apache.org Reply-To: dev@cordova.apache.org References: In-Reply-To: Subject: [GitHub] cordova-ios pull request #232: CB-11270 - Handle JavaScript onclick handler ... Content-Type: text/plain Message-Id: <20160804123525.87D2FE0A7D@git1-us-west.apache.org> Date: Thu, 4 Aug 2016 12:35:25 +0000 (UTC) archived-at: Thu, 04 Aug 2016 12:35:27 -0000 Github user tony-- commented on a diff in the pull request: https://github.com/apache/cordova-ios/pull/232#discussion_r73512881 --- Diff: CordovaLib/Classes/Private/Plugins/CDVIntentAndNavigationFilter/CDVIntentAndNavigationFilter.m --- @@ -95,23 +95,33 @@ - (CDVIntentAndNavigationFilterValue) filterUrl:(NSURL*)url return [[self class] filterUrl:url intentsWhitelist:self.allowIntentsWhitelist navigationsWhitelist:self.allowNavigationsWhitelist]; } -- (BOOL)shouldOverrideLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType ++ (BOOL)shouldOpenURLRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType +{ + return (UIWebViewNavigationTypeLinkClicked == navigationType || + (UIWebViewNavigationTypeOther == navigationType && + [[request.mainDocumentURL absoluteString] isEqualToString:[request.URL absoluteString]] + ) + ); +} + ++ (BOOL)shouldOverrideLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType filterValue:(CDVIntentAndNavigationFilterValue)filterValue { NSString* allowIntents_whitelistRejectionFormatString = @"ERROR External navigation rejected - not set for url='%@'"; NSString* allowNavigations_whitelistRejectionFormatString = @"ERROR Internal navigation rejected - not set for url='%@'"; NSURL* url = [request URL]; - CDVIntentAndNavigationFilterValue filterValue = [self filterUrl:url]; switch (filterValue) { case CDVIntentAndNavigationFilterValueNavigationAllowed: return YES; case CDVIntentAndNavigationFilterValueIntentAllowed: - // only allow-intent if it's a UIWebViewNavigationTypeLinkClicked (anchor tag) - if (UIWebViewNavigationTypeLinkClicked == navigationType) { + // only allow-intent if it's a UIWebViewNavigationTypeLinkClicked (anchor tag) OR + // it's a UIWebViewNavigationTypeOther, and it's an internal link + if ([[self class] shouldOpenURLRequest:request navigationType:navigationType]){ [[UIApplication sharedApplication] openURL:url]; } - // consume the request (i.e. no error) if it wasn't a UIWebViewNavigationTypeLinkClicked + --- End diff -- Got it (especially now that I reread [the doc for the outer method](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIWebViewDelegate_Protocol/#//apple_ref/occ/intfm/UIWebViewDelegate/webView:shouldStartLoadWithRequest:navigationType:))! Thanks for explaining. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org For additional commands, e-mail: dev-help@cordova.apache.org