Closed Bug 1891484 Opened 1 year ago Closed 1 year ago

(`file` schema-denoted) URIs entered into address bar do not interpret environment variables correctly.

Categories

(Core :: XPCOM, defect)

Firefox 124
x86_64
Linux
defect

Tracking

()

RESOLVED WONTFIX

People

(Reporter: zn7esutb, Unassigned)

References

()

Details

I want to visit file://localhost/home/RokeJulianLockhart via the address bar using the $HOME environment variable. However, I am unable to if I utilize $HOME (rather than inputting that path directly) despite $HOME being set:

"$Env:HOME"

produces /home/RokeJulianLockhart.

I've tried all the potentially valid combinations:

  1. "file://$HOME/"
    

    Because $HOME's value of /home/RokeJulianLockhart begins with / (rather than merely home/) omitting one of the slashes should make sense so that there are not 4 slashes. It does not work:

    1. When file://$HOME/RokeJulianLockhart is entered:
    2. It becomes file:///RokeJulianLockhart.
  2. "file:///$HOME/"
    

    Because the 1st option didn't work, one would expect that actually, multiple slashes are removed during interpretation. However, they are not:

    1. When file:///$HOME/RokeJulianLockhart is entered:
    2. It remains file:///$HOME/RokeJulianLockhart.
  3. "file://localhost/$HOME/"
    

    Even explicitly including the (local loopback) hostname doesn't work:

    1. When file://localhost/$HOME/ is entered:
    2. It remains file:///$HOME/.

    However, this would be undesirable anyway, considering that localhost is mere convention, rather than something worth explicitly relying upon instead of absence of hostname

This doesn't make any sense to me.

Summary: `file` schema-denoted URIs entered into address bar do not interpret environment variables correctly. → (`file` schema-denoted) URIs entered into address bar do not interpret environment variables correctly.
OS: Unspecified → Linux
Hardware: Unspecified → x86_64
Version: unspecified → Firefox 124

This would likely be implemented in xpcom/io/nsLocalFileUnix.cpp, so moving to Core / XPCOM (other similar bugs like https://bugzilla.mozilla.org/show_bug.cgi?id=1847572 have been handled there).

Component: Address Bar → XPCOM
Product: Firefox → Core

Thanks, mak@mozilla.com. https://bugzilla.mozilla.org/show_bug.cgi?id=1847572#c0 is similar. (However, I'm surprised that it was implemented - it's very much a bash-specific feature.)

The severity field is not set for this bug.
:nika, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(nika)

I don't think this makes sense to implement support for. In general, file URIs are intended to use absolute paths, and don't pull values from shell environments. I think I'm inclined to mark this WONTFIX, as the URL bar isn't a BASH shell.

Status: UNCONFIRMED → RESOLVED
Closed: 1 year ago
Flags: needinfo?(nika)
Resolution: --- → WONTFIX

https://bugzilla.mozilla.org/show_bug.cgi?id=1891484#c5

nika@thelayzells.com, environment variables are not whatsoever specific to bash. However, I agree that it shouldn't be treated as such. Yet, in that case, why was https://bugzilla.mozilla.org/show_bug.cgi?id=1847572#c0 implemented - a literal bash-specific feature?

Flags: needinfo?(nika)

IIRC the reason support for typing ~/path/to/file into the URL bar was added was due to equivalent support in other browsers like Chrome. IIRC you can't include ~ in a file:/// URI either way, it effectively only impacts typing a bare path in the URL bar. I believe this reasoning isn't also present for the shell $ENV syntax being allowed within file URIs.

Flags: needinfo?(nika)

https://bugzilla.mozilla.org/show_bug.cgi?id=1891484#c7

nika@thelayzells.com, isn't "the shell $ENV syntax what I'm requesting - the ability to use environment variables ($HOME, for instance) in file:// URIs?

Flags: needinfo?(nika)

Yes, I am aware you are requesting the ability to use shell $ENV syntax within file URIs. My comment was explaining how the situation in bug 1847572 is not equivalent to that feature request, in response to your question in comment 6.

Flags: needinfo?(nika)
You need to log in before you can comment on or make changes to this bug.