diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-27 15:18:07 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-27 15:18:07 +0000 |
commit | c6ce48192cf024700cf9faf96ea01acc44d1e4e6 (patch) | |
tree | 4e28be5fda1d3af4b41f1acb067905aeb2fd753e /third_party | |
parent | bb91ce763726b984aa69bb1dc3a8eec359753b3b (diff) | |
download | chromium_src-c6ce48192cf024700cf9faf96ea01acc44d1e4e6.zip chromium_src-c6ce48192cf024700cf9faf96ea01acc44d1e4e6.tar.gz chromium_src-c6ce48192cf024700cf9faf96ea01acc44d1e4e6.tar.bz2 |
Mac: Prevent an NSException from being thrown in -getURLs:andTitles:.
Code shouldn't assume that any given pasteboard type that is promised will
actually be provided.
This "fixes" bug 42420, though kind of incidentally. More importantly, it fixes
a crasher.
Possibly, this should be upstreamed back into Camino.
BUG=42420
TEST=dragging a bookmarklet (e.g., at <http://delicious.com/help/bookmarklets>) from web content to the bookmark bar won't cause a crash
Review URL: http://codereview.chromium.org/1750016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45697 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party')
-rw-r--r-- | third_party/mozilla/NSPasteboard+Utils.mm | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/third_party/mozilla/NSPasteboard+Utils.mm b/third_party/mozilla/NSPasteboard+Utils.mm index 255566e0..bfd87de 100644 --- a/third_party/mozilla/NSPasteboard+Utils.mm +++ b/third_party/mozilla/NSPasteboard+Utils.mm @@ -175,6 +175,7 @@ NSString* const kWebURLsWithTitlesPboardType = @"WebURLsWithTitlesPboardType"; - (void) getURLs:(NSArray**)outUrls andTitles:(NSArray**)outTitles { NSArray* types = [self types]; + NSURL* urlFromNSURL = nil; // Used below in getting an URL from the NSURLPboardType. if ([types containsObject:kWebURLsWithTitlesPboardType]) { NSArray* urlAndTitleContainer = [self propertyListForType:kWebURLsWithTitlesPboardType]; *outUrls = [urlAndTitleContainer objectAtIndex:0]; @@ -215,8 +216,8 @@ NSString* const kWebURLsWithTitlesPboardType = @"WebURLsWithTitlesPboardType"; [(NSMutableArray*) *outUrls addObject:urlString]; [(NSMutableArray*) *outTitles addObject:title]; } - } else if ([types containsObject:NSURLPboardType]) { - *outUrls = [NSArray arrayWithObject:[[NSURL URLFromPasteboard:self] absoluteString]]; + } else if ([types containsObject:NSURLPboardType] && (urlFromNSURL = [NSURL URLFromPasteboard:self])) { + *outUrls = [NSArray arrayWithObject:[urlFromNSURL absoluteString]]; NSString* title = nil; if ([types containsObject:kCorePasteboardFlavorType_urld]) title = [self stringForType:kCorePasteboardFlavorType_urld]; |