-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Allow Bundle IDs that have a valid prefix - strict validation #2515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
c797071
cdf452a
0ce2482
fbc0881
8338fcd
fdd44e2
1d1e1f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,8 @@ | |
|
|
||
| #import "Private/FIRBundleUtil.h" | ||
|
|
||
| #import <GoogleUtilities/GULAppEnvironmentUtil.h> | ||
|
|
||
| @implementation FIRBundleUtil | ||
|
|
||
| + (NSArray *)relevantBundles { | ||
|
|
@@ -45,13 +47,33 @@ + (NSArray *)relevantURLSchemes { | |
| return result; | ||
| } | ||
|
|
||
| + (BOOL)hasBundleIdentifier:(NSString *)bundleIdentifier inBundles:(NSArray *)bundles { | ||
| + (BOOL)hasBundleIdentifierPrefix:(NSString *)bundleIdentifier inBundles:(NSArray *)bundles { | ||
| for (NSBundle *bundle in bundles) { | ||
| if ([bundle.bundleIdentifier isEqualToString:bundleIdentifier]) { | ||
| // This allows app extensions that have the app's bundle as their prefix to pass this test. | ||
| NSString *applicationBundleIdentifier = | ||
| [GULAppEnvironmentUtil isAppExtension] | ||
| ? [self bundleIdentifierByRemovingLastPartFrom:bundleIdentifier] | ||
| : bundleIdentifier; | ||
|
|
||
| if ([applicationBundleIdentifier isEqualToString:bundle.bundleIdentifier]) { | ||
| return YES; | ||
| } | ||
| } | ||
| return NO; | ||
| } | ||
|
|
||
| + (NSString *)bundleIdentifierByRemovingLastPartFrom:(NSString *)bundleIdentifier { | ||
| NSString *bundleIdComponentsSeparator = @"."; | ||
| NSArray<NSString *> *bundleIdComponents = | ||
| [bundleIdentifier componentsSeparatedByString:bundleIdComponentsSeparator]; | ||
| if (bundleIdComponents.count < 2) { | ||
| return @""; | ||
| } | ||
|
|
||
| NSMutableArray<NSString *> *mutableNundleIdComponents = [bundleIdComponents mutableCopy]; | ||
|
||
| [mutableNundleIdComponents removeLastObject]; | ||
|
|
||
| return [mutableNundleIdComponents componentsJoinedByString:bundleIdComponentsSeparator]; | ||
| } | ||
|
|
||
| @end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,8 +45,8 @@ | |
| + (NSArray *)relevantURLSchemes; | ||
|
|
||
| /** | ||
| * Checks if the bundle identifier exists in the given bundles. | ||
| * Checks the given bundles to see of them is a prefix of the given identifier. | ||
|
||
| */ | ||
| + (BOOL)hasBundleIdentifier:(NSString *)bundleIdentifier inBundles:(NSArray *)bundles; | ||
| + (BOOL)hasBundleIdentifierPrefix:(NSString *)bundleIdentifier inBundles:(NSArray *)bundles; | ||
|
|
||
| @end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
bundleIDinstead ofIdhere and below.