Fixed crash in Google Maps SDK, caused by exposing a text property on every object

This commit is contained in:
Leo Natan
2020-12-10 07:27:42 +02:00
parent a8bf52bf5e
commit e849c7e769
5 changed files with 20 additions and 7 deletions
+5 -1
View File
@@ -10,4 +10,8 @@ detox/test/ios/* @LeoNatan
*.m @LeoNatan
*.mm @LeoNatan
*.cpp @LeoNatan
*.sh @rotemmiz
*.swift @LeoNatan
*.pch @LeoNatan
*.plist @LeoNatan
*.sh @rotemmiz
+1 -1
View File
@@ -216,7 +216,7 @@ class Element : NSObject {
@objc
var text: String? {
return view.value(forKey: "text") as? String
return view.value(forKey: "dtx_text") as? String
}
@objc
@@ -193,7 +193,7 @@ BOOL __DTXPointEqualToPoint(CGPoint a, CGPoint b)
- (NSString *)dtx_text
{
id rv = [self text];
id rv = [self _dtx_text];
if(rv == nil || [rv isKindOfClass:NSString.class])
{
return rv;
@@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface NSObject (DontCrash)
- (id)text;
- (id)_dtx_text;
@end
+12 -3
View File
@@ -9,10 +9,19 @@
@implementation NSObject (DontCrash)
- (id)text
- (id)_dtx_text
{
Class cls = NSClassFromString(@"RCTTextView");
if(cls != nil && [self isKindOfClass:cls])
if([self respondsToSelector:@selector(text)])
{
return [(UITextView*)self text];
}
static Class RCTTextView;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
RCTTextView = NSClassFromString(@"RCTTextView");
});
if(RCTTextView != nil && [self isKindOfClass:RCTTextView])
{
return [(NSTextStorage*)[self valueForKey:@"textStorage"] string];
}