From 362af10b8b4776b121d45855fca2dbb8136fe5a7 Mon Sep 17 00:00:00 2001 From: "rflint@ryanflint.com" Date: Wed, 25 Jul 2007 20:59:31 -0700 Subject: [PATCH] Bug 387069 - Exclude empty strings from the duplicate check. r=mconnor --- .../search/content/engineManager.js | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/browser/components/search/content/engineManager.js b/browser/components/search/content/engineManager.js index ff706f0f1eb7..3958b2daaa9c 100644 --- a/browser/components/search/content/engineManager.js +++ b/browser/components/search/content/engineManager.js @@ -164,33 +164,36 @@ var gEngineManagerDialog = { var msg = strings.getFormattedString("editMsg", [selectedEngine.name]); while (prompt.prompt(window, title, msg, alias, null, { })) { - var searchService = Cc["@mozilla.org/browser/search-service;1"]. - getService(Ci.nsIBrowserSearchService); - var engine = searchService.getEngineByAlias(alias.value); var bduplicate = false; var eduplicate = false; - if (engine) { - if (engine.name != selectedEngine.name) - eduplicate = true; - } else { - try { - var bmserv = Cc["@mozilla.org/browser/nav-bookmarks-service;1"]. - getService(Ci.nsINavBookmarksService); - if (bmserv.getURIForKeyword(alias.value)) - bduplicate = true; - } catch(ex) {} + if (alias.value != "") { + var searchService = Cc["@mozilla.org/browser/search-service;1"]. + getService(Ci.nsIBrowserSearchService); + var engine = searchService.getEngineByAlias(alias.value); - // Check for duplicates in changes we haven't committed yet - var engines = gEngineView._engineStore.engines; - for each (var engine in engines) { - if (engine.alias == alias.value && - engine.name != selectedEngine.name) { + if (engine) { + if (engine.name != selectedEngine.name) eduplicate = true; - break; + } else { + try { + var bmserv = Cc["@mozilla.org/browser/nav-bookmarks-service;1"]. + getService(Ci.nsINavBookmarksService); + if (bmserv.getURIForKeyword(alias.value)) + bduplicate = true; + } catch(ex) {} + + // Check for duplicates in changes we haven't committed yet + var engines = gEngineView._engineStore.engines; + for each (var engine in engines) { + if (engine.alias == alias.value && + engine.name != selectedEngine.name) { + eduplicate = true; + break; + } } } - } + } // Notify the user if they have chosen an existing engine/bookmark keyword if (eduplicate || bduplicate) {