by lunarg on July 28th 2017, at 10:31

Safari has an option to automatically open files that are considered "safe". Usually these are document types (e.g. PDF) but sometimes it may become necessary to add other file extensions that are not considered "safe" by default. This can be achieved easily by adding/editing a plist configuration file to your profile (i.e. user-based setting).

The preferences file is located at ~/Library/Preferences/, and determines whether a specific file extension is considered safe or not.

If the file does not yet exist, create it with the contents below:

<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" ""> 
<plist version="1.0"> 

If the file already exists, it's a simple matter of adding additional <string> to the <array> tags as seen in the code above.

By using the preferences file you can categorize file extensions (and content types as well). There are four categories when it comes to downloaded files:

  • LSRiskCategorySafe - "safe" files, which Safari will automatically open when this option has been enabled in Safari (on the General tab).
  • LSRiskCategoryNeutral - neutral files will not be auto-opened but when downloaded, no warnings or prompts will be displayed. This the default behaviour for most unknown file types.
  • LSRiskCategoryUnsafeExecutable - all executable formats fall into this category. A prompt will appear when downloading these files in Safari, or opening these attachments in Mail.
  • LSRiskCategoryMayContainUnsafeExecutable - same as above but the executable file is inside a "container" file, such as DMG or ZIP.

You can leverage this to change the "safe" downloads behaviour to exclude certain file extensions that are normally considered "safe" by Safari (e.g. ZIP-files). Just as you would assign a file extension to the "safe" category, assign the file extension to the LSRiskCategoryNeutral section, marking files as neutral (i.e. consider files safe but do not automatically open them).

To exclude ZIP-files, you would add this to the preferences file:

« December 2023»
« You only find out who is swimming naked when the tide goes out. »
Warren Buffett