Closed Bug 450327 Opened 16 years ago Closed 16 years ago

Local (file:///) files cannot be opened if the filename contains "#".

Categories

(Firefox :: File Handling, defect)

x86
Windows XP
defect
Not set
major

Tracking

()

RESOLVED INVALID

People

(Reporter: root, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9) Gecko/2008052906 Firefox/3.0
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9) Gecko/2008052906 Firefox/3.0

I believe the root cause of this issue is with Firefox and not the LocalLink add-on that I'm using to be able to open local (file:///) files. If I attempt to use LocalLink (via right-click context menu) to open any file with the "#" character in the filename, Firefox says the file cannot be found. 

Example: file:///E:/Temp/Test File#2.txt

This happens regardless of whether I type the above into the address bar or click a link on a Web page. I have tried putting quotes around the whole string and URL encoding/escaping the "#" character but I still get file not found. 

My suspicious is that the root cause is in the way "#" is normally interpreted as an anchor target for most links. However for the file:/// "protocol" it should be interpreted as a part of the whole filename. I haven't tested but if my suspicious are correct for the above example, a file at E:\Temp\Test File should be opened because everything after and including the "#" seems to get truncated when finding the file on the filesystem.

I haven't tested whether this will happen with any other special characters but it seems this is probably a special case.

Reproducible: Always

Steps to Reproduce:
1. Have LocalLink add-on installed or configure Firefox such that opening local links is allowed.
2. Create file on your local drive (LocalLink doesn't seem to let you open files on a mapped network drive) such as C:\Test #1.txt.
3. Create a simple HTML page with a link or type in the address bar: file:///C:/Test #1.txt.
Actual Results:  
Firefox will display a File Not Found page with the correct filename used. For the example in Reproduction Step 2 it would display: Firefox can't find the file at /C:/Test #1.txt. 

Expected Results:  
The file would be found in the filesystem and the appropriate file handler would be called to open the file, OR if no file handler was found a dialog box would prompt the user for what to do.

The following add-ons are installed and enabled:
Adblock 0.5.3.043
Flashblock 1.5.6
FlashGot 1.0.4.5
LocalLink 0.4
Stealther 1.0.6
Toolbar Buttons 0.5.0.5

The following add-ons are installed but disabled:
mediaplayerconnectivity 0.9.1

Just to prove to myself this is not related to any other add-ons I disabled all of them except LocalLink (which is required to attempt this) and the error still persists.
My suspicions were correct. Let's say two files exist on the local filesystem in the same folder; one called "Test" (note this file has no file extension) and "Test #1.txt" in the root of the C: drive. A link pointing to file:///C:/Test #1.txt will indeed open "Test", and not "Test #1.txt" which is not the correct behavior.

I suppose this could be somewhat of a security issue in that the expected file is not the one actually opened. Of course, opening local files from a Web page in Firefox is a security issue to begin with, so the severity of this bug on top of that remains to be judged.
Works fine for me on Mac.  I just have to make sure the "#" in the filename is escaped as "%23".
You're right Jesse, I was escaping it using the HTML encoding, # (if that even displays correctly) not URL encode of %23. Thanks, I'm going to change this to resolved.
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.