Scott's Weblog The weblog of an IT pro focusing on cloud computing, Kubernetes, Linux, containers, and networking

Making File URLs Work Again in Firefox

At some point in the last year or so—I don’t know exactly when it happened—Firefox, along with most of the other major browsers, stopped working with file:// URLs. This is a shame, because I like using Markdown for presentations (at least, when it’s a presentation where I don’t need to collaborate with others). However, using this sort of approach generally requires support for file:// URLs (or requires running a local web server). In this post, I’ll show you how to make file:// URLs work again in Firefox.

I tested this procedure using Firefox 74 on Ubuntu, but it should work on any platform on which Firefox is supported. Note that the locations of the user.js file will vary from OS to OS; see this MozillaZine Knowledge Base entry for more details.

Here’s the process I followed:

  1. Create the user.js file (it doesn’t exist by default) in the correct location for your Firefox profile. (Refer to the MozillaZine KB article linked above for exactly where that is on your OS.)

  2. In the user.js, add these entries:

    // Allow file:// links
    user_pref("capability.policy.policynames", "localfilelinks");
    user_pref("capability.policy.localfilelinks.sites", "file://");
    user_pref("capability.policy.localfilelinks.checkloaduri.enabled", "allAccess");
    
  3. In your Firefox configuration (accessible using about:config in a Firefox tab), change the value of privacy.file_unique_origin from true to false.

  4. Restart Firefox.

After you restart Firefox, you should be able to use file:// URLs, but only from local HTML files on your system (as specified by the second line you added in step 2). It’s possible this may expose an unknown security flaw or weakness that I haven’t foreseen, so keep that in mind.

If you’re a fan of Markdown-based presentations displayed using your browser, they should work again.

Hit me on Twitter if you have questions. Thanks!

Metadata and Navigation

Be social and share this post!