Backtrack:  
 
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/com.apple.DownloadAssessment.plist, 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" "http://www.apple.com-PropertyList-1.0.dtd"> 
<plist version="1.0"> 
    <dict> 
        <key>LSRiskCategorySafe</key> 
        <dict> 
            <key>LSRiskCategoryExtensions</key> 
            <array> 
                <string>docx</string> 
                <string>xlsx</string> 
            </array> 
        </dict> 
    </dict> 
</plist>

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:

<dict> 
    <key>LSRiskCategoryNeutral</key> 
    <dict> 
        <key>LSRiskCategoryExtensions</key> 
        <array> 
            <string>zip</string> 
        </array> 
    </dict> 
</dict>
 
 
« November 2024»
SunMonTueWedThuFriSat
     12
3456789
10111213141516
17181920212223
24252627282930
 
Links
 
Quote
« If the batteries of a TV remote run out, why do we press the buttons so much harder? »