Skip to content

Commit f6f4d32

Browse files
authored
Merge pull request #1090 from AmpMe/fix-1006
Safely inspect bundles for classes
2 parents 7a820b7 + 4cd853c commit f6f4d32

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

Parse/Internal/Object/Subclassing/PFObjectSubclassingController.m

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,20 +128,12 @@ - (void)scanForUnregisteredSubclasses:(BOOL)shouldSubscribe {
128128
queue:nil
129129
usingBlock:^(NSNotification *note) {
130130
@strongify(self);
131-
[self _registerSubclassesInBundle:note.object];
131+
[self _registerSubclassesInLoadedBundle:note.object];
132132
}];
133133
}
134134
NSArray *bundles = [[NSBundle allFrameworks] arrayByAddingObjectsFromArray:[NSBundle allBundles]];
135135
for (NSBundle *bundle in bundles) {
136-
// Skip bundles that aren't loaded yet.
137-
if (!bundle.loaded || !bundle.executablePath) {
138-
continue;
139-
}
140-
// Filter out any system bundles
141-
if ([bundle.bundlePath hasPrefix:@"/System/"] || [bundle.bundlePath hasPrefix:@"/Library/"]) {
142-
continue;
143-
}
144-
[self _registerSubclassesInBundle:bundle];
136+
[self _registerSubclassesInLoadedBundle:bundle];
145137
}
146138
}
147139

@@ -338,6 +330,18 @@ - (void)_rawRegisterSubclass:(Class)kls {
338330
_registeredSubclasses[[kls parseClassName]] = subclassInfo;
339331
}
340332

333+
- (void)_registerSubclassesInLoadedBundle:(NSBundle *)bundle {
334+
// Skip bundles that aren't loaded yet.
335+
if (!bundle.loaded || !bundle.executablePath) {
336+
return;
337+
}
338+
// Filter out any system bundles
339+
if ([bundle.bundlePath hasPrefix:@"/System/"] || [bundle.bundlePath hasPrefix:@"/Library/"] || [bundle.bundlePath rangeOfString:@"iPhoneSimulator.sdk"].location != NSNotFound) {
340+
return;
341+
}
342+
[self _registerSubclassesInBundle:bundle];
343+
}
344+
341345
- (void)_registerSubclassesInBundle:(NSBundle *)bundle {
342346
PFConsistencyAssert(bundle.loaded, @"Cannot register subclasses in a bundle that hasn't been loaded!");
343347

0 commit comments

Comments
 (0)