alibaba/BeeHive

可能的逻辑错误

Opened this issue · 2 comments

BeeHive/BeeHive/BHRouter.m

Lines 590 to 596 in ff7aef5

+ (id)safePerformAction:(SEL)action
forTarget:(NSObject *)target
withParams:(NSDictionary *)params
{
NSMethodSignature * sig = [self methodSignatureForSelector:action];
if (!sig) { return nil; }
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:sig];

这里应该调用的是[target methodSignatureForSelector:action] ,而不是[self methodSignatureForSelector:action],这里的self是BHRouter


BeeHive/BeeHive/BHRouter.m

Lines 275 to 285 in ff7aef5

Protocol *protocol = NSProtocolFromString(protocolStr);
SEL selector = NSSelectorFromString(selectorStr);
if (!protocol ||
!selector ||
![mClass conformsToProtocol:@protocol(BHServiceProtocol)] ||
![mClass conformsToProtocol:protocol] ||
![mClass respondsToSelector:selector]) {
flag = NO;
*stop = NO;
return;
}

service的selector是限定只能调用实例方法吗?貌似是的,URL中定义并未区分同签名的实例方法和类方法;这里存在矛盾的地方,canOpenURL 里判断selector时
确又是只判断了类方法


BeeHive/BeeHive/BHRouter.m

Lines 245 to 255 in ff7aef5

NSArray<NSString *> *pathComponents = URL.pathComponents;
__block BOOL flag = YES;
[pathComponents enumerateObjectsUsingBlock:^(NSString * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
NSArray<NSString *> * subPaths = [obj componentsSeparatedByString:BHRURLSubPathSplitPattern];
if (!subPaths.count) {
flag = NO;
*stop = NO;
return;
}

如果打开一个https://call.service.beehive/BBSGroupServiceImpl.BBSGroupService.groupViewController#push链接,此处pathComponents值是[@"/",@"BBSGroupServiceImpl.BBSGroupService.groupViewController"}}],会始终被认为flag为NO,应该排除@"/",应和openURL逻辑一致

BeeHive/BeeHive/BHRouter.m

Lines 353 to 356 in ff7aef5

[pathComponents enumerateObjectsUsingBlock:^(NSString * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if (![obj isEqualToString:@"/"]) {
NSArray<NSString *> * subPaths = [obj componentsSeparatedByString:BHRURLSubPathSplitPattern];

xilin commented

看起来前两个问题是在f8a9e51这个commit中修改了