file:// needs to expand ~ to home directory in some OS
Categories
(Firefox :: Address Bar, enhancement, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox118 | --- | fixed |
People
(Reporter: jmd, Assigned: vinny.diehl)
References
()
Details
Attachments
(1 file)
Reporter | ||
Comment 2•23 years ago
|
||
Comment 5•23 years ago
|
||
Comment 7•23 years ago
|
||
Updated•23 years ago
|
Comment 10•23 years ago
|
||
Comment 11•23 years ago
|
||
Comment 12•23 years ago
|
||
Comment 13•22 years ago
|
||
Comment 14•22 years ago
|
||
Comment 15•22 years ago
|
||
Comment 16•21 years ago
|
||
Comment 19•17 years ago
|
||
Comment 20•17 years ago
|
||
Comment 21•17 years ago
|
||
Comment 24•14 years ago
|
||
Comment 25•13 years ago
|
||
Updated•9 years ago
|
Comment 26•7 years ago
|
||
Updated•2 years ago
|
Assignee | ||
Comment 28•1 year ago
•
|
||
IMO this should be an address bar bug rather than nkfile, as one should be able to access the home directory simply by typing ~
into the address bar, rather than needing to specify file://~
.
This behavior was implemented in Chromium with this commit, ~/foo
gets expanded to e.g. file:///home/username/foo
, and ~foo/bar
is expanded to file:///home/foo/bar
. Explicitly typing file://~/foo
in Chrome does not expand to a valid filepath (it falls through to a search), but perhaps we can do better and support both ways? Either way, the path should be fully expanded by the time it reaches Necko.
I plan on looking into this soon, as I place one-off temporary test files in ~
quite often, and even for files nested deeper within the home directory it is convenient to go to ~
and then click around the directories from there.
Comment 29•1 year ago
•
|
||
If we're going to do it, it should probably be in URIFixup: https://searchfox.org/mozilla-central/rev/fb43eb3bdf5b51000bc7dfe3474cbe56ca2ab63c/docshell/base/URIFixup.sys.mjs#915,929,935-939
The fix may be as easy as changing the uriString.startsWith("/")
with /^(~$|~?\/)/.test(uriString)
, plus adding some tests for ~
and ~/path
and some negative non-matching tests.
Assignee | ||
Comment 30•1 year ago
|
||
(In reply to Marco Bonardo [:mak] from comment #29)
The fix may be as easy as changing the
uriString.startsWith("/")
with/^(~$|~?\/)/.test(uriString)
, plus adding some tests for~
and~/path
and some negative non-matching tests.
Wow, that was easy! /^[~/]/
appears to be sufficient for the regex. I've submitted a patch for review- you might suggest a better, more explicit way to test for the home dir (I'm currently using a regex that doesn't care what the user name is).
Home dirs for other users (e.g. ~foo/bar
-> file:///home/foo/bar
) are not yet supported- this might be something to do with nsIFile.initWithPath
? I can't for the life of me find the implementation for this, if we decide that this addition is important, a nudge in the right direction would be appreciated.
Assignee | ||
Comment 31•1 year ago
|
||
Updated•1 year ago
|
Comment 32•1 year ago
|
||
(In reply to Vinny Diehl from comment #30)
Home dirs for other users (e.g.
~foo/bar
->file:///home/foo/bar
) are not yet supported- this might be something to do withnsIFile.initWithPath
? I can't for the life of me find the implementation for this, if we decide that this addition is important, a nudge in the right direction would be appreciated.
Does that work in Chromium?
Comment 33•1 year ago
•
|
||
Apparently nsLocalFileUnix only handles ~
or ~/abcd
: https://searchfox.org/mozilla-central/rev/fb43eb3bdf5b51000bc7dfe3474cbe56ca2ab63c/xpcom/io/nsLocalFileUnix.cpp#310-311
My initial regex was indeed based on that, as I didn't know ~abcde
was a valid path. To add support for that a bug should be filed under Core :: XPCOM component to modify nsLocalFileUnix.cpp.
Assignee | ||
Comment 34•1 year ago
•
|
||
(In reply to Marco Bonardo [:mak] from comment #32)
Does that work in Chromium?
It does.
(In reply to Marco Bonardo [:mak] from comment #33)
My initial regex was indeed based on that, as I didn't know
~abcde
was a valid path. To add support for that a bug should be filed under Core :: XPCOM component to modify nsLocalFileUnix.cpp.
Okay, sounds good. Filed as Bug 1847572.
Comment 35•1 year ago
|
||
In the Address Bar we'll take the approach in comment 28, I think that's reasonable and a parity bug.
It's unclear whether the original proposal is still worth it after 12 years of inactivity.
Though, before moving on, I'ld to get an opinion from network since this bug was moved from there. Should we move this back and file a new Address Bar bug?
Comment 36•1 year ago
|
||
(In reply to Marco Bonardo [:mak] (away 11-21 Aug) from comment #35)
In the Address Bar we'll take the approach in comment 28, I think that's reasonable and a parity bug.
It's unclear whether the original proposal is still worth it after 12 years of inactivity.
The approach in comment 28 looks reasonable to me. It looks like the URL spec doesn't require expanding ~
to home directory, so I think supporting this in Address Bar is right.
Though, before moving on, I'ld to get an opinion from network since this bug was moved from there. Should we move this back and file a new Address Bar bug?
Instead of moving this bug back, I think we can take the patch in this bug and file a new one if necessary. Thanks.
Comment 37•1 year ago
|
||
Comment 38•1 year ago
|
||
bugherder |
Updated•1 year ago
|
Description
•