Skip to content

Commit

Permalink
Merge pull request #8311 from hansemannn/TIMOB-23797-5_5_X
Browse files Browse the repository at this point in the history
[TIMOB-23858] (5_5_X) Detect and warn corrupt UTI-type
  • Loading branch information
cheekiatng committed Sep 5, 2016
2 parents 973853d + d35f124 commit eb19583
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions iphone/Classes/TiUIClipboardProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ -(void)clearData:(id)arg
case CLIPBOARD_UNKNOWN:
default:
{
NSData *data = [[NSData alloc] init];
[board setData:data forPasteboardType: mimeTypeToUTType(mimeType)];
[data release];
[[UIPasteboard generalPasteboard] setItems:@[]];
}
}
}
Expand Down Expand Up @@ -330,13 +328,29 @@ -(id)getItems:(id)unused
{
#if IS_XCODE_8
if ([TiUtils isIOS10OrGreater]) {
__block id result;
__block id items;

TiThreadPerformOnMainThread(^{
result = [[[UIPasteboard generalPasteboard] items] retain];
items = [[[UIPasteboard generalPasteboard] items] retain];

// Check for invalid UTI's / mime-types to prevent a runtime-crash
for (NSDictionary *item in items) {
for (NSString *key in [item allKeys]) {
if ([key hasPrefix:@"dyn."]) {
NSLog(@"[ERROR] Invalid mime-type specified to setItems() before. Returning an empty result ...");

RELEASE_TO_NIL(items);
items = @[];
break;
}
}
if ([items count] == 0) {
break;
}
}
}, YES);

return [result autorelease];
return [items autorelease];
}
#endif

Expand Down

0 comments on commit eb19583

Please sign in to comment.