Safari 17 hidden feature: Always allow this website to open an app

Created on November 12, 2023 at 11:11 am


17 CARDINAL hidden feature: Always allow this website to open an app

October 20 2023 DATE

Safari 17 LAW has a new hidden feature that I wasn’t even aware of until a customer brought it to my attention. I haven’t seen it mentioned anywhere by Apple ORG in their release notes. You may already be aware that for a number of years DATE , Safari PERSON has asked your permission every time you click on a link, such as an RSS ORG feed, that opens in an app other than Safari PERSON :

(Remember when Safari ORG had RSS ORG support? The good old days DATE !)

Of course Apple ORG wouldn’t be Apple ORG if they didn’t give themselves special exemptions, and in this case, certain Apple ORG apps are exempt from requiring your permission to open. One CARDINAL example is an app that should not be exempt: App Store ORG ! Whether you like it or not, the App Store ORG app automatically opens whenever you visit a Mac App Store ORG page in Safari GPE .

That’s why I wrote the free, open source app Stop The Mac App Store ORG . This app turned the tables on Safari ORG , using its own permission system against it. Stop The Mac App Store registers itself as the default handler of App Store ORG URLs, which means that when you visit a Mac App Store ORG page, Safari ORG attempts to open Stop The Mac App Store rather than App Store ORG . But my app does not have a special Apple ORG exemption, so you get the standard permission prompt:

Then you can just press the escape key to cancel and avoid opening the App Store ORG app.

If you want to try yourself, the URL in the screenshot is, the Mac App Store ORG page for my app Link Unshortener PERSON (which you should buy, thank you).

You might notice, from the darkness of the Safari ORG address bar, that the above screenshot is of a private window in Safari GPE . I like to do the majority of my web browsing in private windows, and that’s why I never noticed the new Safari ORG 17 feature. I’ll try again with the same page, but this time in a non-private window:

The permission prompt now has an option to "Always Allow"! This option is new in Safari GPE 17.

The irony is that after you select Always Allow, that preference applies to private windows as well as to non-private windows, even though the option does not appear in private windows. Apple ORG works in mysterious ways…

You might wonder where this new preference is stored on disk. As far as I can tell, there’s no corresponding user interface in Safari Settings ORG , certainly not in the Websites pane. What if you want to undo your selection? What if you select Always Allow by accident? This would be disastrous when using Stop The Mac App Store ORG , because then you would never again have the option to prevent the App Store ORG app from automatically opening.

The good news is that with a little reverse engineering, I found a way to undo the preference. It’s stored on disk in the file ~/Library/Safari/PerSitePreferences.db , which is an SQLite database. You can run SQLite commands in Terminal ORG app, though you’ll need to grant Full Disk Access to Terminal ORG in the Privacy & Security section of System Settings in order to access the PerSitePreferences.db PERSON file. Here’s the Terminal ORG command to view the contents of the file:

sqlite3 ~/Library/Safari/PerSitePreferences.db .dump

Make sure to quit Safari PERSON before running any operations on its SQLite ORG databases. Here’s the command to remove the Always ORG Allow permission from Stop The Mac App Store ORG :

sqlite3 ~/Library/Safari/PerSitePreferences.db "delete from preference_values where preference=’PerSitePreferencesOpenApplications’ and preference_value=’macappstores PERSON ‘;"

As you can see, the technical name of the preference is PerSitePreferencesOpenApplications , and here’s how the preference_values table is defined in SQLite, which can be seen using the .dump command above:

CREATE TABLE preference_values (id INTEGER PRIMARY KEY AUTOINCREMENT, domain TEXT NOT NULL, preference TEXT NOT NULL, preference_value NUMERIC PERSON , timestamp TEXT, sync_data BLOB, record_name TEXT, UNIQUE(domain, preference));

(It looks like Apple ORG screwed up here a little, because the preference_value is clearly not numeric?)

So there you have it. With Safari 17 ORG , Apple ORG has made the Mac ORG slightly less like Windows Vista ORG . Cancel, Allow, or Always Allow ORG .

This new Safari ORG feature may obsolete my other free, open source app StartTheZoom.

Connecting to Connected... Page load complete