Fix bugs in smart keyword import

git-svn-id: svn://10.0.0.236/branches/MIGRATION_20040101_BRANCH@151495 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
ben%bengoodger.com
2004-01-18 11:24:16 +00:00
parent aa36f1692e
commit b96f43db66

View File

@@ -820,7 +820,7 @@ nsOperaProfileMigrator::CopySmartKeywords(nsIBookmarksService* aBMS,
PRInt32 sectionIndex = 1;
char section[35];
char *name = nsnull, *url = nsnull, *keyword = nsnull;
char *name = nsnull, *url = nsnull, *keyword = nsnull, *isPost = nsnull;
PRInt32 keyValueLength = 0;
do {
sprintf(section, "Search Engine %d", sectionIndex++);
@@ -832,10 +832,38 @@ nsOperaProfileMigrator::CopySmartKeywords(nsIBookmarksService* aBMS,
if (err != nsINIParser::OK)
continue;
err = parser->GetStringAlloc(section, "Key", &keyword, &keyValueLength);
if (err != nsINIParser::OK)
continue;
err = parser->GetStringAlloc(section, "Is post", &isPost, &keyValueLength);
if (err != nsINIParser::OK)
continue;
nsAutoString nameStr(NS_ConvertUTF8toUCS2(name));
if (nsDependentCString(url).IsEmpty() ||
nsDependentCString(keyword).IsEmpty() ||
nsDependentCString(name).IsEmpty())
continue;
PRInt32 stringErr;
PRInt32 post = nsCAutoString(isPost).ToInteger(&stringErr);
if (post)
continue;
nsAutoString nameStr; nameStr.Assign(NS_ConvertUTF8toUCS2(name));
PRUint32 length = nameStr.Length();
PRInt32 index = 0;
do {
index = nameStr.FindChar('&', index);
if (index >= length - 2)
break;
if (nameStr.CharAt(index + 1) == '&')
continue;
nameStr.Cut(index, 1);
break;
}
while (1);
nsCOMPtr<nsIRDFResource> itemRes;
nsCOMPtr<nsIURI> uri;
@@ -851,7 +879,7 @@ nsOperaProfileMigrator::CopySmartKeywords(nsIBookmarksService* aBMS,
aBundle->FormatStringFromName(NS_LITERAL_STRING("importedSearchUrlDesc").get(),
descStrings, 2, getter_Copies(keywordDesc));
rv = aBMS->CreateBookmarkInContainer(NS_ConvertUTF8toUCS2(name).get(),
rv = aBMS->CreateBookmarkInContainer(nameStr.get(),
url,
NS_ConvertUTF8toUCS2(keyword).get(),
keywordDesc.get(),