Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/apache/cordova-ios into v…
Browse files Browse the repository at this point in the history
…erbose-spec-reporter
  • Loading branch information
Christopher J. Brody committed Feb 16, 2020
2 parents b4193eb + bce99f9 commit 5585fee
Show file tree
Hide file tree
Showing 116 changed files with 4,628 additions and 6,187 deletions.
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ bin/node_modules/*
bin/templates/project/*
tests/spec/unit/fixtures/*
CordovaLib/cordova.js

# Non-JS binaries
bin/test
bin/cordova_plist_to_config_xml
bin/templates/scripts/cordova/log
bin/templates/scripts/cordova/lib/start-emulator
34 changes: 25 additions & 9 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
# 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.

root: true
extends: semistandard
rules:
indent:
- error
- 4
camelcase: off
padded-blocks: off
operator-linebreak: off
no-throw-literal: off
extends: '@cordova/eslint-config/node'

overrides:
- files: [tests/spec/**/*.js]
extends: '@cordova/eslint-config/node-tests'

- files: [cordova-js-src/**/*.js]
extends: '@cordova/eslint-config/browser'
13 changes: 4 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@ sudo: false

matrix:
include:
# Run one test with Xcode 9.x, the rest with 10.1
- osx_image: xcode9.3
env: TRAVIS_NODE_VERSION=10
- osx_image: xcode10.1
env: TRAVIS_NODE_VERSION=6
- osx_image: xcode10.1
env: TRAVIS_NODE_VERSION=8
- osx_image: xcode10.1
- osx_image: xcode11
env: TRAVIS_NODE_VERSION=10
- osx_image: xcode11
env: TRAVIS_NODE_VERSION=12

before_install:
- nvm install $TRAVIS_NODE_VERSION
Expand All @@ -24,7 +19,7 @@ install:
script:
- node --version
- npm --version
- npm run eslint
- npm run lint
- npm run unit-tests
- npm run test:component
- npm run e2e-tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#import <Cordova/CDVPlugin.h>
#import <Cordova/CDVWhitelist.h>

#define CDVWebViewNavigationType int

typedef NS_ENUM(NSInteger, CDVIntentAndNavigationFilterValue) {
CDVIntentAndNavigationFilterValueIntentAllowed,
CDVIntentAndNavigationFilterValueNavigationAllowed,
Expand All @@ -29,6 +31,6 @@ typedef NS_ENUM(NSInteger, CDVIntentAndNavigationFilterValue) {
@interface CDVIntentAndNavigationFilter : CDVPlugin <NSXMLParserDelegate>

+ (CDVIntentAndNavigationFilterValue) filterUrl:(NSURL*)url intentsWhitelist:(CDVWhitelist*)intentsWhitelist navigationsWhitelist:(CDVWhitelist*)navigationsWhitelist;
+ (BOOL)shouldOverrideLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType filterValue:(CDVIntentAndNavigationFilterValue)filterValue;
+ (BOOL)shouldOpenURLRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType;
+ (BOOL)shouldOverrideLoadWithRequest:(NSURLRequest*)request navigationType:(CDVWebViewNavigationType)navigationType filterValue:(CDVIntentAndNavigationFilterValue)filterValue;
+ (BOOL)shouldOpenURLRequest:(NSURLRequest*)request navigationType:(CDVWebViewNavigationType)navigationType;
@end
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,18 @@ + (CDVIntentAndNavigationFilterValue) filterUrl:(NSURL*)url intentsWhitelist:(CD
{
// a URL can only allow-intent OR allow-navigation, if both are specified,
// only allow-navigation is allowed

BOOL allowNavigationsPass = [navigationsWhitelist URLIsAllowed:url logFailure:NO];
BOOL allowIntentPass = [intentsWhitelist URLIsAllowed:url logFailure:NO];

if (allowNavigationsPass && allowIntentPass) {
return CDVIntentAndNavigationFilterValueNavigationAllowed;
} else if (allowNavigationsPass) {
return CDVIntentAndNavigationFilterValueNavigationAllowed;
} else if (allowIntentPass) {
return CDVIntentAndNavigationFilterValueIntentAllowed;
}

return CDVIntentAndNavigationFilterValueNoneAllowed;
}

Expand All @@ -95,46 +95,47 @@ - (CDVIntentAndNavigationFilterValue) filterUrl:(NSURL*)url
return [[self class] filterUrl:url intentsWhitelist:self.allowIntentsWhitelist navigationsWhitelist:self.allowNavigationsWhitelist];
}

+ (BOOL)shouldOpenURLRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
#define CDVWebViewNavigationTypeLinkClicked 0
#define CDVWebViewNavigationTypeLinkOther -1

+ (BOOL)shouldOpenURLRequest:(NSURLRequest*)request navigationType:(CDVWebViewNavigationType)navigationType
{
return (UIWebViewNavigationTypeLinkClicked == navigationType ||
(UIWebViewNavigationTypeOther == navigationType &&
[[request.mainDocumentURL absoluteString] isEqualToString:[request.URL absoluteString]]
)
);
return (
navigationType == CDVWebViewNavigationTypeLinkClicked ||
navigationType == CDVWebViewNavigationTypeLinkOther
);
}

+ (BOOL)shouldOverrideLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType filterValue:(CDVIntentAndNavigationFilterValue)filterValue
+ (BOOL)shouldOverrideLoadWithRequest:(NSURLRequest*)request navigationType:(CDVWebViewNavigationType)navigationType filterValue:(CDVIntentAndNavigationFilterValue)filterValue
{
NSString* allowIntents_whitelistRejectionFormatString = @"ERROR External navigation rejected - <allow-intent> not set for url='%@'";
NSString* allowNavigations_whitelistRejectionFormatString = @"ERROR Internal navigation rejected - <allow-navigation> not set for url='%@'";

NSURL* url = [request URL];

switch (filterValue) {
case CDVIntentAndNavigationFilterValueNavigationAllowed:
return YES;
case CDVIntentAndNavigationFilterValueIntentAllowed:
// only allow-intent if it's a UIWebViewNavigationTypeLinkClicked (anchor tag) OR
// it's a UIWebViewNavigationTypeOther, and it's an internal link
// only allow-intent if it's a CDVWebViewNavigationTypeLinkClicked (anchor tag) or CDVWebViewNavigationTypeOther and it's an internal link
if ([[self class] shouldOpenURLRequest:request navigationType:navigationType]){
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
}

// consume the request (i.e. no error) if it wasn't handled above
return NO;
case CDVIntentAndNavigationFilterValueNoneAllowed:
// allow-navigation attempt failed for sure
NSLog(@"%@", [NSString stringWithFormat:allowNavigations_whitelistRejectionFormatString, [url absoluteString]]);
// anchor tag link means it was an allow-intent attempt that failed as well
if (UIWebViewNavigationTypeLinkClicked == navigationType) {
if (CDVWebViewNavigationTypeLinkClicked == navigationType) {
NSLog(@"%@", [NSString stringWithFormat:allowIntents_whitelistRejectionFormatString, [url absoluteString]]);
}
return NO;
}
}

- (BOOL)shouldOverrideLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
- (BOOL)shouldOverrideLoadWithRequest:(NSURLRequest*)request navigationType:(CDVWebViewNavigationType)navigationType
{
return [[self class] shouldOverrideLoadWithRequest:request navigationType:navigationType filterValue:[self filterUrl:request.URL]];
}
Expand Down

This file was deleted.

Loading

0 comments on commit 5585fee

Please sign in to comment.