From b96f43db66d5cf4eb5902aa7da51435fb721df7a Mon Sep 17 00:00:00 2001 From: "ben%bengoodger.com" Date: Sun, 18 Jan 2004 11:24:16 +0000 Subject: [PATCH] Fix bugs in smart keyword import git-svn-id: svn://10.0.0.236/branches/MIGRATION_20040101_BRANCH@151495 18797224-902f-48f8-a5cc-f745e15eee43 --- .../migration/src/nsOperaProfileMigrator.cpp | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/mozilla/browser/components/migration/src/nsOperaProfileMigrator.cpp b/mozilla/browser/components/migration/src/nsOperaProfileMigrator.cpp index 1face422a61..64439906168 100644 --- a/mozilla/browser/components/migration/src/nsOperaProfileMigrator.cpp +++ b/mozilla/browser/components/migration/src/nsOperaProfileMigrator.cpp @@ -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 itemRes; nsCOMPtr 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(),