Fix when print log string which contains special control characters in doric,cause native crash

This commit is contained in:
pengfei.zhou
2023-02-09 14:06:47 +08:00
committed by jingpeng
parent 54ecddf994
commit fc4628dde9
27 changed files with 895 additions and 1172 deletions

View File

@@ -41,7 +41,17 @@ - (void)onException:(NSException *)exception inContext:(DoricContext *)context {
}
- (void)onLog:(DoricLogType)type message:(NSString *)message {
DoricLog(message);
switch (type) {
case DoricLogTypeWarning:
DoricSafeLog([@"Doric-W: " stringByAppendingString:message]);
break;
case DoricLogTypeError:
DoricSafeLog([@"Doric-E: " stringByAppendingString:message]);
break;
default:
DoricSafeLog([@"Doric-D: " stringByAppendingString:message]);
break;
}
}
@end
@@ -335,7 +345,7 @@ - (void)callbackTimer:(NSTimer *)timer {
}
- (id)jsValueToObject:(JSValue *)jsValue {
if([jsValue isKindOfClass:NSDictionary.class]){
if ([jsValue isKindOfClass:NSDictionary.class]) {
return jsValue;
}
return [jsValue toObjectWithArrayBuffer];