From 45bd5bb7cd365c85fc0486d8fcc900da5b4880a7 Mon Sep 17 00:00:00 2001 From: "law%netscape.com" Date: Wed, 17 May 2006 02:32:57 +0000 Subject: [PATCH] Bug 60708; prevent user from creating helper app entries with blank mime type fields; r=pchen, sr=ben --- suite/common/pref/overrideHandler.js | 19 +++++++++++++++++++ suite/common/pref/pref-applications-edit.xul | 4 ++++ .../common/pref/pref-applications.properties | 4 +++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/suite/common/pref/overrideHandler.js b/suite/common/pref/overrideHandler.js index 4424ae7d297c..62b54a5d4f7c 100644 --- a/suite/common/pref/overrideHandler.js +++ b/suite/common/pref/overrideHandler.js @@ -403,3 +403,22 @@ function removeOverride(aMIMEType) } } } + +function checkInput() { + var result = true; + // Check for empty MIME type field. + if ( gMIMEField.value == "" ) { + // Input is not OK. + result = false; + + // Focus the mime type field. + gMIMEField.focus(); + + // Put up alert. Title is same as parent dialog's. + var title = window.document.documentElement.getAttribute( "title" ); + var text = gPrefApplicationsBundle.getString("emptyMIMEType"); + var prompter = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService); + prompter.alert(window, title, text); + } + return result; +} diff --git a/suite/common/pref/pref-applications-edit.xul b/suite/common/pref/pref-applications-edit.xul index 891b77896945..ef17b5b74169 100644 --- a/suite/common/pref/pref-applications-edit.xul +++ b/suite/common/pref/pref-applications-edit.xul @@ -178,6 +178,10 @@ function onAccept() { + // Validate input. + if ( !checkInput() ) { + return false; + } getDS(); // figure out if this mime type already exists. if (gMIMEField.value != gOldMIME) { diff --git a/suite/locales/en-US/chrome/common/pref/pref-applications.properties b/suite/locales/en-US/chrome/common/pref/pref-applications.properties index e70bb087ef7a..5a8e92c1cece 100644 --- a/suite/locales/en-US/chrome/common/pref/pref-applications.properties +++ b/suite/locales/en-US/chrome/common/pref/pref-applications.properties @@ -9,5 +9,7 @@ programsFilter=Programs handlerExists=A helper already exists for the MIME type '%mime%'. Do you want to replace it? handlerExistsTitle=Helper Application Exists +emptyMIMEType=You must specify a MIME type. + removeHandlerTitle=Remove File Type -removeHandler=If you remove a registered type, the helper will no longer be able to automatically handle files of this type. %n%nAre you sure you want to remove this file type? \ No newline at end of file +removeHandler=If you remove a registered type, the helper will no longer be able to automatically handle files of this type. %n%nAre you sure you want to remove this file type?