Closed Bug 816851 Opened 12 years ago Closed 11 years ago

[OS.File] All relative paths should be taken as relative to the profile directory

Categories

(Toolkit Graveyard :: OS.File, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 908138

People

(Reporter: Yoric, Unassigned)

References

Details

Doing so would make much more sense and would make code more concise and more readable.

This requires three steps:
- introduce a function OS.Path.isRelative in ospath_unix_back.jsm and ospath_win_path.jsm;
- introduce a normalization function (let's call it OS.AbstractFile.normalizePath) that leaves absolute paths unchanged and return OS.Path.join(OS.Constants.Path.profileDir, path) on relative paths;
- ensure that all functions of OS.File call this normalization function to normalize their path arguments.
I don't understand why you picked the profile directory, instead of the app directory or some other location. I would recommend that you just disallow relative paths altogether, because if they are relative to the CWD they can be a security hazard and relative to anywhere else is not an obvious behavior.
This was a request by users of the API, during the design of bug 813833.
One issue with using the profile directory is that it might be the wrong profile directory.  Eg, we store thumbnails in "the profile", but they are stored in the "temp" profile directory rather than the "real" profile directory (excuse my imprecise terms - I'm not sure what the correct names for these are, but on Windows, the "temp" profile is the one under "AppData/Local" versus the "real" one under "AppData/Roaming").

Forcing people to be explicit is better and less error prone IMO, so I agree with comment 1 - just disallow relative paths completely.
Replacing this bug with bug 908138.
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → DUPLICATE
Product: Toolkit → Toolkit Graveyard
You need to log in before you can comment on or make changes to this bug.