From cf82bbbca4ec422edfb475ef87e735e4c62b8b12 Mon Sep 17 00:00:00 2001 From: "joshmoz%gmail.com" Date: Sat, 20 Nov 2004 00:39:13 +0000 Subject: [PATCH] fix bug 265503 - firefox bookmark importing fixes. sr=pinkerton git-svn-id: svn://10.0.0.236/trunk@165534 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/camino/src/bookmarks/BookmarkManager.mm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mozilla/camino/src/bookmarks/BookmarkManager.mm b/mozilla/camino/src/bookmarks/BookmarkManager.mm index 87852e722b3..4877275e3dd 100644 --- a/mozilla/camino/src/bookmarks/BookmarkManager.mm +++ b/mozilla/camino/src/bookmarks/BookmarkManager.mm @@ -791,15 +791,19 @@ static unsigned gFirstUserCollection = 0; currentItem = [currentArray addBookmark]; [(Bookmark *)currentItem setUrl:[tempItem stringByRemovingAmpEscapes]]; [tokenScanner scanUpToString:@">" intoString:&tempItem]; - [currentItem setTitle:[[tokenString substringFromIndex:([tokenScanner scanLocation]+1)] stringByRemovingAmpEscapes]]; - justSetTitle = YES; + if (![tokenScanner isAtEnd]) { // protect against malformed files + [currentItem setTitle:[[tokenString substringFromIndex:([tokenScanner scanLocation]+1)] stringByRemovingAmpEscapes]]; + justSetTitle = YES; + } // see if we had a keyword if (isNetscape) { tempRange = [tempItem rangeOfString:@"SHORTCUTURL=\"" options: NSCaseInsensitiveSearch]; if (tempRange.location != NSNotFound) { - // throw everything to next " into keyword + // throw everything to next " into keyword. A malformed bookmark might not have a closing " which + // will throw things out of whack slightly, but it's better than crashing. keyRange = [tempItem rangeOfString:@"\"" options:0 range:NSMakeRange(tempRange.location+tempRange.length,[tempItem length]-(tempRange.location+tempRange.length))]; - [currentItem setKeyword:[tempItem substringWithRange:NSMakeRange(tempRange.location+tempRange.length,keyRange.location - (tempRange.location+tempRange.length))]]; + if (keyRange.location != NSNotFound) + [currentItem setKeyword:[tempItem substringWithRange:NSMakeRange(tempRange.location+tempRange.length,keyRange.location - (tempRange.location+tempRange.length))]]; } } }