file://localhost/ issues

Opera's goofy. It uses "file://localhost/" instead of "file:///" to represent paths to local files on your hard drive. All other browsers use "file:///".

"file://localhost/" is bad because barely anything supports it, which causes major compatibility problems for Opera.

For example, when a plug-in on a local web page reads document.location (for determining the base URI of a page, or the path to a file when you load a file directly and a plug-in is set to handle that file type), the plug-in will get a URI with "file://localhost/" in it, which will break the loading of the file because the code that plug-ins use to convert a file: path to a native path doesn't take "localhost" into account.

Also, for most programs, if the progam is passed a file URI on the command line, the program will convert it to a native path so that the file loads. But, again, this will fail if the file URI comes from Opera as it'll have "file://localhost/" in it.

Opera works around this issue for some popular plug-ins. But, it doesn't work around this for all plug-ins.

Another area that Opera doesn't work around this is with the "open with other application" "pass web address directly to application" option. If you click a link to a local mp3 for example that's set to pass directly to foobar2000.exe, the file won't play because foobar will generate an incorrect native path because the file URI has "file://localhost" in it.

To work around that issue, don't use "pass web address directly to application". Or, use a program/script as a command proxy that converts "file://localhost/" to "file:///". An example of such a program for vlc.exe (videolan) is located at <http://files.myopera.com/burnout426/files/vlc_opera.zip>. The source is easily editable so that you can adapt it for use with other exes. To compile it, use <http://nuwen.net/mingw.html>.

For Videolan, it has code that handles both "file:///" and "file://localhost/". But, the "file://localhost/" handling it has only works for Mac paths. There's a fix for this in video 1.2 to make this work on windows too, hopefully.

wmplayer.exe will load the correct file when passed a file URI with "file://localhost/" in it. But, the path in the properties of that entry in the playlist will be corrupted.

As for Opera fixing this problem, it's bug CORE-40495. People have been trying to get Opera to use "file:///" for years, but Opera hasn't fixed this. Add your support in the comments and the forums if you want this fixed.

There are 20 comments on this page. [Display and/or add comments]