Fix when print log string which contains special control characters in doric,cause native crash
This commit is contained in:
@@ -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];
|
||||
|
@@ -27,8 +27,11 @@
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
void DoricLog(NSString *_Nonnull format, ...);
|
||||
|
||||
void DoricSafeLog(NSString *_Nonnull message);
|
||||
|
||||
UIColor *_Nonnull DoricColor(NSNumber *_Nonnull number);
|
||||
|
||||
NSNumber *_Nonnull DoricColorToNumber(UIColor *_Nonnull color);
|
||||
@@ -50,6 +53,7 @@ void ShowToastInVC(UIViewController *_Nonnull vc, NSString *_Nonnull text, Doric
|
||||
UIImage *_Nonnull UIImageWithColor(UIColor *_Nonnull color);
|
||||
|
||||
BOOL hasNotch(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -31,6 +31,10 @@ void DoricLog(NSString *_Nonnull format, ...) {
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void DoricSafeLog(NSString *_Nonnull message) {
|
||||
NSLog(@"%@", message);
|
||||
}
|
||||
|
||||
UIColor *DoricColor(NSNumber *number) {
|
||||
CGFloat r, g, b, a;
|
||||
long colorValue = [number longValue];
|
||||
|
Reference in New Issue
Block a user