cxfeng1 closed pull request #1807: [iOS] Protect invalid rich-text data. URL: https://github.com/apache/incubator-weex/pull/1807
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/ios/sdk/WeexSDK/Sources/Component/WXRichText.mm b/ios/sdk/WeexSDK/Sources/Component/WXRichText.mm index 833c7d48af..c985d23fcd 100644 --- a/ios/sdk/WeexSDK/Sources/Component/WXRichText.mm +++ b/ios/sdk/WeexSDK/Sources/Component/WXRichText.mm @@ -25,6 +25,7 @@ #import "WXComponent+Layout.h" #import "WXNavigationProtocol.h" #import "WXImgLoaderProtocol.h" +#import "WXLog.h" #include <pthread/pthread.h> @interface WXRichNode : NSObject @@ -214,6 +215,16 @@ - (void)fillAttributes:(NSDictionary *)attributes toNode:(WXRichNode *)node supe - (void)recursivelyAddChildNode:(NSDictionary *)nodeValue toSuperNode:(WXRichNode *)superNode { + if (![nodeValue isKindOfClass:[NSDictionary class]]) { + WXLogError(@"Invalid rich text structure."); + return; + } + + if (![nodeValue[@"type"] isKindOfClass:[NSString class]]) { + WXLogError(@"Invalid rich text structure."); + return; + } + WXRichNode *node = [[WXRichNode alloc]init]; [_richNodes addObject:node]; ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services