Bug 1472635 - Prevent suppressing executable warnings using the "don't ask me this again" checkbox. r=Gijs

A hidden preference matching "browser.download.manager.alertOnEXEOpen" is kept, but is renamed in order to recover cases where the checkbox was used accidentally.

This also cleans up duplicate unused strings in the "browser" folder.

MozReview-Commit-ID: GyccRiyoVGs

--HG--
extra : rebase_source : 8211ad1c94894535b2b98dde0549d7ab52a879b0
This commit is contained in:
Paolo Amadini 2018-07-02 15:42:58 +01:00
parent 644be8856b
commit 86d16ff4dd
5 changed files with 20 additions and 42 deletions

View File

@ -63,7 +63,6 @@ const kDownloadsStringsRequiringFormatting = {
sizeWithUnits: true,
statusSeparator: true,
statusSeparatorBeforeNumber: true,
fileExecutableSecurityWarning: true
};
const kDownloadsStringsRequiringPluralForm = {

View File

@ -92,10 +92,6 @@ sizeUnknown=Unknown size
statusSeparator=%1$S \u2014 %2$S
statusSeparatorBeforeNumber=%1$S \u2014 %2$S
fileExecutableSecurityWarning=“%S” is an executable file. Executable files may contain viruses or other malicious code that could harm your computer. Use caution when opening this file. Are you sure you want to launch “%S”?
fileExecutableSecurityWarningTitle=Open Executable File?
fileExecutableSecurityWarningDontAsk=Dont ask me this again
# LOCALIZATION NOTE (otherDownloads3):
# This is displayed in an item at the bottom of the Downloads Panel when
# there are more downloads than can fit in the list in the panel. Use a

View File

@ -107,51 +107,35 @@ this.DownloadPrompter.prototype = {
/**
* Displays a warning message box that informs that the specified file is
* executable, and asks whether the user wants to launch it. The user is
* given the option of disabling future instances of this warning.
* executable, and asks whether the user wants to launch it.
*
* @param aPath
* @param path
* String containing the full path to the file to be opened.
*
* @return {Promise}
* @resolves Boolean indicating whether the launch operation can continue.
* @rejects JavaScript exception.
*/
confirmLaunchExecutable(aPath) {
const kPrefAlertOnEXEOpen = "browser.download.manager.alertOnEXEOpen";
async confirmLaunchExecutable(path) {
const kPrefSkipConfirm = "browser.download.skipConfirmLaunchExecutable";
// Always launch in case we have no prompter implementation.
if (!this._prompter) {
return true;
}
try {
// Always launch in case we have no prompter implementation.
if (!this._prompter) {
return Promise.resolve(true);
if (Services.prefs.getBoolPref(kPrefSkipConfirm)) {
return true;
}
try {
if (!Services.prefs.getBoolPref(kPrefAlertOnEXEOpen)) {
return Promise.resolve(true);
}
} catch (ex) {
// If the preference does not exist, continue with the prompt.
}
let leafName = OS.Path.basename(aPath);
let s = DownloadUIHelper.strings;
let checkState = { value: false };
let shouldLaunch = this._prompter.confirmCheck(
s.fileExecutableSecurityWarningTitle,
s.fileExecutableSecurityWarning(leafName, leafName),
s.fileExecutableSecurityWarningDontAsk,
checkState);
if (shouldLaunch) {
Services.prefs.setBoolPref(kPrefAlertOnEXEOpen, !checkState.value);
}
return Promise.resolve(shouldLaunch);
} catch (ex) {
return Promise.reject(ex);
// If the preference does not exist, continue with the prompt.
}
let leafName = OS.Path.basename(path);
let s = DownloadUIHelper.strings;
return this._prompter.confirm(s.fileExecutableSecurityWarningTitle,
s.fileExecutableSecurityWarning(leafName,
leafName));
},
/**

View File

@ -106,7 +106,6 @@ yesterday=Yesterday
fileExecutableSecurityWarning=“%S” is an executable file. Executable files may contain viruses or other malicious code that could harm your computer. Use caution when opening this file. Are you sure you want to launch “%S”?
fileExecutableSecurityWarningTitle=Open Executable File?
fileExecutableSecurityWarningDontAsk=Dont ask me this again
# Desktop folder name for downloaded files
downloadsFolder=Downloads

View File

@ -25,9 +25,9 @@ const PREFS_WHITELIST = [
"browser.download.hide_plugins_without_extensions",
"browser.download.lastDir.savePerSite",
"browser.download.manager.addToRecentDocs",
"browser.download.manager.alertOnEXEOpen",
"browser.download.manager.resumeOnWakeDelay",
"browser.download.preferred.",
"browser.download.skipConfirmLaunchExecutable",
"browser.download.useDownloadDir",
"browser.fixup.",
"browser.history_expire_",