local file:// links in chrome or edge - google-chrome

Having file:// links within a website e.g. http://localhost will not open because of security reason.
In IE and Firefox it's possible to allow such access either in the "Trusted Sites" & "Local Intranet" from IE or to configure a policy in Firefox:
I can't figure out a way in Chrome or Edge. Searching the web I came across solutions like the --allow-file-access-from-files flag, but that does not work in Chrome 77.0.
Also there are some extensions which enable that behavior:
Enable local file links
I believe there must be some similar way with policies like in Firefox?
EDIT: update 22.03.2021
Chrome Version 89.0.4389.90
Edge Version 89.0.774.57
Result:
Not allowed to load local resource: file:///D:/temp/demo.pdf
Demo HTML:
<html>
<body>
file://fileserver/demo.pdf<br/>
file:///d:/temp/demo.pdf extra slash according to https://en.wikipedia.org/wiki/File_URI_scheme
</body>
</html>

[Update 2022]
As mentioned by flavio.donze, since Edge v95 there is a new policy:
IntranetFileLinksEnabled
https://learn.microsoft.com/en-us/DeployEdge/microsoft-edge-policies#intranetfilelinksenabled
Allow intranet zone file URL links from Microsoft Edge to open in Windows File Explorer
If you enable this policy, intranet zone file URL links originating from intranet zone HTTPS pages will open Windows File Explorer for that file or directory.
So to get this to work, you have to use HTTPS and specify the site as a site being in the intranet zone.
[Outdated - old answer]
Yes, there is a similar policy in Edge (v88 or later), but it only works in conjunction with IEMode:
InternetExplorerIntegrationLocalFileExtensionAllowList
https://learn.microsoft.com/en-us/deployedge/microsoft-edge-policies#internetexplorerintegrationlocalfileallowed
When a file:// URL is requested to launch in Internet Explorer mode, the file extension of the URL must be present in this list in order for the URL to be allowed to launch in Internet Explorer mode. A URL which is blocked from opening in Internet Explorer mode will instead open in Edge mode.
InternetExplorerIntegrationLocalFileShowContextMenu
https://learn.microsoft.com/en-us/deployedge/microsoft-edge-policies#internetexplorerintegrationlocalfileshowcontextmenu
This policy controls the visibility of the 'Open link in new Internet Explorer mode tab' option on the context menu for file:// links.
InternetExplorerIntegrationLevel: IEMode (1) = Internet Explorer mode
https://learn.microsoft.com/en-us/deployedge/microsoft-edge-policies#internetexplorerintegrationlevel
[Other browsers]
The alternatives are, as you already stated above in your question:
Use Firefox with the local file links policy
Use a Chrome/Edge extension, e.g. Enable local file links

There is a new GPO introduced in Edge 95: IntranetFileLinksEnabled
But as stated here, it might only solve the problem for some scenarios: https://stackoverflow.com/questions/69708560/edge-policy-intranetfilelinksenabled-enabled-does-not-open-file
Because only the windows-explorer is opened and not the actual file:
file://power/share/demo.txt<br/>
file://power/share/demo.docx<br/>
file://power/share/demo.pdf<br/>
file://power/share/demo.html<br/>
This setting allows file URL links to intranet zone files from
intranet zone HTTPS websites to open Windows File Explorer for that
file or directory.
If you enable this policy, intranet zone file URL links originating
from intranet zone HTTPS pages will open Windows File Explorer for
that file or directory.
If you disable or don't configure this policy, file URL links will not
open.

Related

PDF not opening in my browser in production

I have a Razor MVC application that contains a link to open a PDF stored on a file server. My code works when I run it in Visual Studio but is not working when I try it on production on the same computer. I click the link and nothing happens, I can see the path when I hover over it though. There are no errors or anything. I've tried all browsers but only really care about IE.
View
Image when I hover over the link
Any ideas why this is not working?
Filesystem URLs from remote pages (i.e. pages on other protocols like http:// or even other directories in the file system) are blocked by modern browsers for security reasons.
Here is a page describing the behaviour for Firefox (along with reasons why it exists).
Internet Explorer has joined the ranks of these modern browsers:
By default, Internet Explorer prevents navigation to Uniform Resource
Identifiers (URIs) using the "file:" protocol when the current URL
matches the following conditions:
The current URL is opened in the Internet zone or the Restricted Sites zone.
The current URL uses a protocol other than "file:".
This is a security measure designed to
prevent malicious sites from accessing system file objects.
This can be changed, but only on a per-client basis (see the MSDN article for details.)

Chrome - add site to local intranet

We are trying to have href links to local shares in our web site.
Under IE if we set the site to the local intranet zone, the links work.
Under Firefox, if we set the site permissions using the user.js file, the link works.
In chrome, even after adding the site to the local intranet zone, file links still do not work.
Any ideas?
I had the same issue recently. I found that IE would grant access to the site if the URL was listed in the local intranet zone website list.
Control Panel > Network and Internet > Internet Options > Security > Local intranet > Sites > Advanced
However, Chrome would not. We had to place the fully qualified domain name of the server
For example:
http://host.company.com/ = BAD (worked for IE, not chrome)
*.company.topic.com = GOOD (worked for both)
Side note: using an asterisk *.company.com may be a solution in your case, but I am unsure of the security flaws (if any) that may introduce.

How do you get WebGL Inspector to show up in Chrome?

In Chrome, I have the WebGL Inspector extension installed. The debug option does not show up in the address bar for the page I'm working on (that I'm using WebGL in). It shows up for other pages on the web. What are the requirements for getting it to give me the debug option?
I guess that you are trying to debug a local file (file://). If so, navigate to chrome://settings/extensions, expand the WebGL Inspector item and check "Allow access to file URLs".
Note: (outdated?) "readme.md" says:
You cannot inspect pages on file:// in WebKit (possible with security settings?)
You can also install a web server on your local PC to dispatch your page from a http:// url.

local link in HTML

This is HTML link to google:
Google
And it work fine
This is a link to my local file:
Local
And its not working, why?
If this is some sort of security issue, so how can I work around it? It's just for my own testing.
This sort of link to a local file will work in some browsers as long as the HTML is also called from a local file. If not, it's a security vulnerability. It won't work at all in webkit based browsers.
See <A>nchor Link to Local File? (<a href='file:///{path}'>DEAD LINK</a> not working in FireFox but in IE)
And Cross-browser link to file on local system
Due to Mozilla’s security model(as well as other modern browsers too), file://-links to local files on your computer or files on a network share do not work on (non-local) web pages; a click on such a link just does nothing. Links to local files could be useful on intranet sites like wikis.
There's an extension named LocalLink(http://locallink.mozdev.org/) for FireFox (and Thunderbird), that adds a new entry “Open Link in Local Context” to the link’s context menu. After you have installed the extension from https://addons.mozilla.org/firefox/addon/281 , you can open file://-links by right click on the link and select “Open Link in Local Context > Current Window”.

Launch file:// from Firefox or Chrome

I am looking for a way to launch a file located on our local file network for use via our local intranet using Firefox or Chrome.
The link works well in IE:
View Report
but in Firefox it shows:
View Report
is there a way to get the link to render properly?...Just a simple click from a href tag.
For Chrome, a new extension was just posted today! It's called LocalLinks and it replicates the functionality of the locallink add-on for Firefox! You'll find it on the Google Extensions page, or you can get to it directly here:
https://chrome.google.com/extensions/detail/jllpkdkcdjndhggodimiphkghogcpida
Enjoy!
This is not enabled in firefox for security reasons (remember that most computers have files and applications of a sensitive nature located in similar locations, like C:\System\Windows)
you can try adding this to the user.js file for any user that needs to be able to access these links:
user_pref("capability.policy.policynames", "localfilelinks");
user_pref("capability.policy.localfilelinks.sites", "file:///[[PUT SERVER NAME HERE]]";);
user_pref("capability.policy.localfilelinks.checkloaduri.enabled", "allAccess");
Just remember that this is a security risk.
Firefox seems to want file://///Start/Of/My/Network/file.xlsx
Chrome and IE handles that too.
file://Start/Of/My/Network/file.xlsx appears to work in Chrome as well, sometimes firefox hics up on it..
There is the LocalLink add-on for firefox. It uses a context menu though...
Use IE tab (available for Chrome and Firefox) and set that to handle all links of the form file:/// by adding an autourls entry like this:
r/file:///.*
Technically this isn't opening the file in the original browser, but it gives you all the windows explorer integration you'd expect from whatever IE version you've got installed when dealing with local file links. I would advise against doing this except in cases when the browser isn't being used to access the web - e.g. for viewing internal wiki or intranet pages, due to the obvious security risk.