mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1752159 - check if target is executable before offering always opening, r=mhowell,mtigley
Depends on D137152 Differential Revision: https://phabricator.services.mozilla.com/D137153
This commit is contained in:
parent
9f3032dc53
commit
377caf35ba
@ -325,6 +325,9 @@ var DownloadsViewUI = {
|
||||
mimeInfo.type === "application/octet-stream" ||
|
||||
mimeInfo.type === "application/x-msdownload" ||
|
||||
mimeInfo.type === "application/x-msdos-program" ||
|
||||
gReputationService.isExecutable(
|
||||
PathUtils.filename(download.target.path)
|
||||
) ||
|
||||
(mimeInfo.type === "text/plain" &&
|
||||
gReputationService.isBinary(download.target.path));
|
||||
|
||||
|
@ -1971,3 +1971,10 @@ nsresult ApplicationReputationService::IsBinary(const nsACString& aFileName,
|
||||
*aBinary = ::IsBinary(aFileName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult ApplicationReputationService::IsExecutable(const nsACString& aFileName,
|
||||
bool* aExecutable) {
|
||||
*aExecutable =
|
||||
::IsFileType(aFileName, sExecutableExts, ArrayLength(sExecutableExts));
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -60,6 +60,17 @@ interface nsIApplicationReputationService : nsISupports {
|
||||
* The filename to check.
|
||||
*/
|
||||
bool isBinary(in AUTF8String aFilename);
|
||||
|
||||
/**
|
||||
* Check if a file with this name should be treated as an executable,
|
||||
* and should not be opened without caution.
|
||||
* Will return true if the filename's extension is in sExecutableExts
|
||||
* in nsLocalFileCommon.h.
|
||||
*
|
||||
* @param aFilename
|
||||
* The filename to check.
|
||||
*/
|
||||
bool isExecutable(in AUTF8String aFilename);
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user