Skip to content

Commit 61268f0

Browse files
authored
Merge pull request #1078 from BranchMetrics/CORE-1198-rename-some-classes
CORE-1198 rename some classes
2 parents 9f8e71b + bff58e4 commit 61268f0

File tree

11 files changed

+173
-173
lines changed

11 files changed

+173
-173
lines changed

Branch-SDK/BNCPreferenceHelper.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@ NSURL* /* _Nonnull */ BNCURLForBranchDirectory(void);
4646
@property (strong, nonatomic) NSString *browserUserAgentString;
4747
@property (strong, atomic) NSString *referringURL;
4848
@property (strong, atomic) NSString *branchAPIURL;
49-
@property (nonatomic, strong, readwrite) NSString *branchBlacklistURL;
5049
@property (assign, atomic) BOOL limitFacebookTracking;
5150
@property (strong, atomic) NSDate *previousAppBuildDate;
5251
@property (assign, nonatomic, readwrite) BOOL disableAdNetworkCallouts;
5352

5453
@property (strong, nonatomic, readwrite) NSURL *faceBookAppLink;
5554

56-
@property (strong, atomic) NSArray<NSString*> *URLBlackList;
57-
@property (assign, atomic) NSInteger URLBlackListVersion;
58-
@property (assign, atomic) BOOL blacklistURLOpen;
55+
@property (nonatomic, strong, readwrite) NSString *patternListURL;
56+
@property (strong, atomic) NSArray<NSString*> *savedURLPatternList;
57+
@property (assign, atomic) NSInteger savedURLPatternListVersion;
58+
@property (assign, atomic) BOOL dropURLOpen;
5959

6060
@property (assign, nonatomic) BOOL sendCloseRequests;
6161

Branch-SDK/BNCPreferenceHelper.m

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ - (instancetype)init {
107107
_persistPrefsQueue = [[NSOperationQueue alloc] init];
108108
_persistPrefsQueue.maxConcurrentOperationCount = 1;
109109

110-
self.branchBlacklistURL = @"https://cdn.branch.io";
110+
self.patternListURL = @"https://cdn.branch.io";
111111
self.disableAdNetworkCallouts = NO;
112112
}
113113
return self;
@@ -551,41 +551,41 @@ - (void) setPreviousAppBuildDate:(NSDate*)date {
551551
}
552552
}
553553

554-
- (NSArray<NSString*>*) URLBlackList {
554+
- (NSArray<NSString*>*) savedURLPatternList {
555555
@synchronized(self) {
556-
id a = [self readObjectFromDefaults:@"URLBlackList"];
556+
id a = [self readObjectFromDefaults:@"URLPatternList"];
557557
if ([a isKindOfClass:NSArray.class]) return a;
558558
return nil;
559559
}
560560
}
561561

562-
- (void) setURLBlackList:(NSArray<NSString *> *)URLBlackList {
562+
- (void) setSavedURLPatternList:(NSArray<NSString *> *)URLPatternList {
563563
@synchronized(self) {
564-
[self writeObjectToDefaults:@"URLBlackList" value:URLBlackList];
564+
[self writeObjectToDefaults:@"URLPatternList" value:URLPatternList];
565565
}
566566
}
567567

568-
- (NSInteger) URLBlackListVersion {
568+
- (NSInteger) savedURLPatternListVersion {
569569
@synchronized(self) {
570-
return [self readIntegerFromDefaults:@"URLBlackListVersion"];
570+
return [self readIntegerFromDefaults:@"URLPatternListVersion"];
571571
}
572572
}
573573

574-
- (void) setURLBlackListVersion:(NSInteger)URLBlackListVersion {
574+
- (void) setSavedURLPatternListVersion:(NSInteger)URLPatternListVersion {
575575
@synchronized(self) {
576-
[self writeIntegerToDefaults:@"URLBlackListVersion" value:URLBlackListVersion];
576+
[self writeIntegerToDefaults:@"URLPatternListVersion" value:URLPatternListVersion];
577577
}
578578
}
579579

580-
- (BOOL) blacklistURLOpen {
580+
- (BOOL) dropURLOpen {
581581
@synchronized(self) {
582-
return [self readBoolFromDefaults:@"blacklistURLOpen"];
582+
return [self readBoolFromDefaults:@"dropURLOpen"];
583583
}
584584
}
585585

586-
- (void) setBlacklistURLOpen:(BOOL)value {
586+
- (void) setDropURLOpen:(BOOL)value {
587587
@synchronized(self) {
588-
[self writeBoolToDefaults:@"blacklistURLOpen" value:value];
588+
[self writeBoolToDefaults:@"dropURLOpen" value:value];
589589
}
590590
}
591591

Branch-SDK/BNCURLBlackList.h

Lines changed: 0 additions & 41 deletions
This file was deleted.

Branch-SDK/BNCURLFilter.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
@file BNCURLFilter.h
3+
@package Branch-SDK
4+
@brief Manages a list of sensitive URLs such as login data that should not be handled by Branch.
5+
6+
@author Edward Smith
7+
@date February 14, 2018
8+
@copyright Copyright © 2018 Branch. All rights reserved.
9+
*/
10+
11+
#if __has_feature(modules)
12+
@import Foundation;
13+
#else
14+
#import <Foundation/Foundation.h>
15+
#endif
16+
17+
@interface BNCURLFilter : NSObject
18+
19+
/**
20+
@brief Checks if a given URL should be ignored.
21+
22+
@param url The URL to be checked.
23+
@return Returns true if the provided URL should be ignored.
24+
*/
25+
- (BOOL) shouldIgnoreURL:(NSURL*_Nullable)url;
26+
27+
/**
28+
@brief Returns the pattern that matches a URL, if any.
29+
30+
@param url The URL to be checked.
31+
@return Returns the pattern matching the URL or `nil` if no patterns match.
32+
*/
33+
- (NSString*_Nullable) patternMatchingURL:(NSURL*_Nullable)url;
34+
35+
/// Refreshes the list of ignored URLs from the server.
36+
- (void) updatePatternListWithCompletion:(void (^_Nullable) (NSError*_Nullable error, NSArray*_Nullable list))completion;
37+
38+
/// Is YES if the listed has already been updated from the server.
39+
@property (assign, readonly) BOOL hasUpdatedPatternList;
40+
@property (strong) NSArray<NSString*>*_Nullable patternList;
41+
@end
Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
@file BNCURLBlackList.m
2+
@file BNCURLFilter.m
33
@package Branch-SDK
44
@brief Manages a list of URLs that we should ignore.
55
@@ -8,27 +8,27 @@
88
@copyright Copyright © 2018 Branch. All rights reserved.
99
*/
1010

11-
#import "BNCURLBlackList.h"
11+
#import "BNCURLFilter.h"
1212
#import "Branch.h"
1313

14-
@interface BNCURLBlackList () {
15-
NSArray<NSString*>*_blackList;
14+
@interface BNCURLFilter () {
15+
NSArray<NSString*>*_patternList;
1616
}
17-
@property (strong) NSArray<NSRegularExpression*> *blackListRegex;
18-
@property (assign) NSInteger blackListVersion;
17+
@property (strong) NSArray<NSRegularExpression*> *ignoredURLRegex;
18+
@property (assign) NSInteger listVersion;
1919
@property (strong) id<BNCNetworkServiceProtocol> networkService;
20-
@property (assign) BOOL hasRefreshedBlackListFromServer;
20+
@property (assign) BOOL hasUpdatedPatternList;
2121
@property (strong) NSError *error;
22-
@property (strong) NSURL *blackListJSONURL;
22+
@property (strong) NSURL *jsonURL;
2323
@end
2424

25-
@implementation BNCURLBlackList
25+
@implementation BNCURLFilter
2626

2727
- (instancetype) init {
2828
self = [super init];
2929
if (!self) return self;
3030

31-
self.blackList = @[
31+
self.patternList = @[
3232
@"^fb\\d+:",
3333
@"^li\\d+:",
3434
@"^pdk\\d+:",
@@ -37,16 +37,16 @@ - (instancetype) init {
3737
@"^(?i)(?!(http|https):).*(:|:.*\\b)(password|o?auth|o?auth.?token|access|access.?token)\\b",
3838
@"^(?i)((http|https):\\/\\/).*[\\/|?|#].*\\b(password|o?auth|o?auth.?token|access|access.?token)\\b",
3939
];
40-
self.blackListVersion = -1; // First time always refresh the list version, version 0.
40+
self.listVersion = -1; // First time always refresh the list version, version 0.
4141

42-
NSArray *storedList = [BNCPreferenceHelper preferenceHelper].URLBlackList;
42+
NSArray *storedList = [BNCPreferenceHelper preferenceHelper].savedURLPatternList;
4343
if (storedList.count > 0) {
44-
self.blackList = storedList;
45-
self.blackListVersion = [BNCPreferenceHelper preferenceHelper].URLBlackListVersion;
44+
self.patternList = storedList;
45+
self.listVersion = [BNCPreferenceHelper preferenceHelper].savedURLPatternListVersion;
4646
}
4747

4848
NSError *error = nil;
49-
_blackListRegex = [self.class compileRegexArray:self.blackList error:&error];
49+
_ignoredURLRegex = [self.class compileRegexArray:self.patternList error:&error];
5050
self.error = error;
5151

5252
return self;
@@ -57,24 +57,24 @@ - (void) dealloc {
5757
self.networkService = nil;
5858
}
5959

60-
- (void) setBlackList:(NSArray<NSString *> *)blackList {
60+
- (void) setPatternList:(NSArray<NSString *> *)patternList {
6161
@synchronized (self) {
62-
_blackList = blackList;
63-
_blackListRegex = [self.class compileRegexArray:_blackList error:nil];
62+
_patternList = patternList;
63+
_ignoredURLRegex = [self.class compileRegexArray:_patternList error:nil];
6464
}
6565
}
6666

67-
- (NSArray<NSString*>*) blackList {
67+
- (NSArray<NSString*>*) patternList {
6868
@synchronized (self) {
69-
return _blackList;
69+
return _patternList;
7070
}
7171
}
7272

73-
+ (NSArray<NSRegularExpression*>*) compileRegexArray:(NSArray<NSString*>*)blacklist
73+
+ (NSArray<NSRegularExpression*>*) compileRegexArray:(NSArray<NSString*>*)patternList
7474
error:(NSError*_Nullable __autoreleasing *_Nullable)error_ {
7575
if (error_) *error_ = nil;
7676
NSMutableArray *array = [NSMutableArray new];
77-
for (NSString *pattern in blacklist) {
77+
for (NSString *pattern in patternList) {
7878
NSError *error = nil;
7979
NSRegularExpression *regex =
8080
[NSRegularExpression regularExpressionWithPattern:pattern
@@ -90,40 +90,40 @@ - (void) setBlackList:(NSArray<NSString *> *)blackList {
9090
return array;
9191
}
9292

93-
- (NSString*_Nullable) blackListPatternMatchingURL:(NSURL*_Nullable)url {
93+
- (NSString*_Nullable) patternMatchingURL:(NSURL*_Nullable)url {
9494
NSString *urlString = url.absoluteString;
9595
if (urlString == nil || urlString.length <= 0) return nil;
9696
NSRange range = NSMakeRange(0, urlString.length);
9797

98-
for (NSRegularExpression* regex in self.blackListRegex) {
98+
for (NSRegularExpression* regex in self.ignoredURLRegex) {
9999
NSUInteger matches = [regex numberOfMatchesInString:urlString options:0 range:range];
100100
if (matches > 0) return regex.pattern;
101101
}
102102

103103
return nil;
104104
}
105105

106-
- (BOOL) isBlackListedURL:(NSURL *)url {
107-
return ([self blackListPatternMatchingURL:url]) ? YES : NO;
106+
- (BOOL) shouldIgnoreURL:(NSURL *)url {
107+
return ([self patternMatchingURL:url]) ? YES : NO;
108108
}
109109

110-
- (void) refreshBlackListFromServer {
111-
[self refreshBlackListFromServerWithCompletion:nil];
110+
- (void) updatePatternList {
111+
[self updatePatternListWithCompletion:nil];
112112
}
113113

114-
- (void) refreshBlackListFromServerWithCompletion:(void (^) (NSError*error, NSArray*list))completion {
114+
- (void) updatePatternListWithCompletion:(void (^) (NSError*error, NSArray*list))completion {
115115
@synchronized(self) {
116-
if (self.hasRefreshedBlackListFromServer) {
117-
if (completion) completion(self.error, self.blackList);
116+
if (self.hasUpdatedPatternList) {
117+
if (completion) completion(self.error, self.patternList);
118118
return;
119119
}
120-
self.hasRefreshedBlackListFromServer = YES;
120+
self.hasUpdatedPatternList = YES;
121121
}
122122

123123
self.error = nil;
124-
NSString *urlString = [self.blackListJSONURL absoluteString];
124+
NSString *urlString = [self.jsonURL absoluteString];
125125
if (!urlString) {
126-
urlString = [NSString stringWithFormat:@"%@/sdk/uriskiplist_v%ld.json", [BNCPreferenceHelper preferenceHelper].branchBlacklistURL, (long) self.blackListVersion+1];
126+
urlString = [NSString stringWithFormat:@"%@/sdk/uriskiplist_v%ld.json", [BNCPreferenceHelper preferenceHelper].patternListURL, (long) self.listVersion+1];
127127
}
128128
NSMutableURLRequest *request =
129129
[NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString]
@@ -135,7 +135,7 @@ - (void) refreshBlackListFromServerWithCompletion:(void (^) (NSError*error, NSAr
135135
[self.networkService networkOperationWithURLRequest:request completion:
136136
^(id<BNCNetworkOperationProtocol> operation) {
137137
[self processServerOperation:operation];
138-
if (completion) completion(self.error, self.blackList);
138+
if (completion) completion(self.error, self.patternList);
139139
[self.networkService cancelAllOperations];
140140
self.networkService = nil;
141141
}
@@ -149,9 +149,9 @@ - (void) processServerOperation:(id<BNCNetworkOperationProtocol>)operation {
149149
if (operation.responseData)
150150
responseString = [[NSString alloc] initWithData:operation.responseData encoding:NSUTF8StringEncoding];
151151
if (operation.response.statusCode == 404) {
152-
BNCLogDebugSDK(@"No new BlackList refresh found.");
152+
BNCLogDebugSDK(@"No new URL ignore list found.");
153153
} else {
154-
BNCLogDebugSDK([NSString stringWithFormat:@"BlackList refresh result. Error: %@ status: %ld body:\n%@.",
154+
BNCLogDebugSDK([NSString stringWithFormat:@"URL ignore list update result. Error: %@ status: %ld body:\n%@.",
155155
operation.error, (long)operation.response.statusCode, responseString]);
156156
}
157157
if (operation.error || operation.responseData == nil || operation.response.statusCode != 200) {
@@ -166,16 +166,16 @@ - (void) processServerOperation:(id<BNCNetworkOperationProtocol>)operation {
166166
return;
167167
}
168168

169-
NSArray *blackListURLs = dictionary[@"uri_skip_list"];
170-
if (![blackListURLs isKindOfClass:NSArray.class]) return;
169+
NSArray *urls = dictionary[@"uri_skip_list"];
170+
if (![urls isKindOfClass:NSArray.class]) return;
171171

172-
NSNumber *blackListVersion = dictionary[@"version"];
173-
if (![blackListVersion isKindOfClass:NSNumber.class]) return;
172+
NSNumber *version = dictionary[@"version"];
173+
if (![version isKindOfClass:NSNumber.class]) return;
174174

175-
self.blackList = blackListURLs;
176-
self.blackListVersion = [blackListVersion longValue];
177-
[BNCPreferenceHelper preferenceHelper].URLBlackList = self.blackList;
178-
[BNCPreferenceHelper preferenceHelper].URLBlackListVersion = self.blackListVersion;
175+
self.patternList = urls;
176+
self.listVersion = [version longValue];
177+
[BNCPreferenceHelper preferenceHelper].savedURLPatternList = self.patternList;
178+
[BNCPreferenceHelper preferenceHelper].savedURLPatternListVersion = self.listVersion;
179179
}
180180

181181
@end

Branch-SDK/Branch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) {
645645
646646
These are ICU standard regular expressions.
647647
*/
648-
@property (copy, nullable) NSArray<NSString*>/*_Nullable*/* blackListURLRegex;
648+
@property (copy, nullable) NSArray<NSString*>/*_Nullable*/* urlPatternsToIgnore;
649649

650650
/**
651651
Register your Facebook SDK's FBSDKAppLinkUtility class to be used by Branch for deferred deep linking from their platform

0 commit comments

Comments
 (0)