Open Bug 696891 Opened 14 years ago Updated 3 years ago

Files created from native paths count "." as a valid part of the path name

Categories

(Core :: XPCOM, defect)

x86
macOS
defect

Tracking

()

People

(Reporter: ehsan.akhgari, Unassigned)

References

Details

If you create an nsLocalFile with a path name like "/Users/ehsanakhgari/moz/mozgit/obj-ff-dbg/dist/NightlyDebug.app/Contents/MacOS/./application.ini", and then call GetParent on it, you'll get an nsIFile pointing to "/Users/ehsanakhgari/moz/mozgit/obj-ff-dbg/dist/NightlyDebug.app/Contents/MacOS/.". I believe that this is not correct, and GetParent should be pointing to "/Users/ehsanakhgari/moz/mozgit/obj-ff-dbg/dist/NightlyDebug.app/Contents/MacOS" instead. I'm not sure if this is the desired behavior, and if not, how to fix it. This can lead to some weird corner cases where we would end up picking the wrong directory for performing background updates.
What does python do? We normally operate on files lexically in which case the current behavior would be correct and you'd need to normalize a file in order to get the parent that you expect. But I'm willing to be convinced that maybe we should automatically normalize when .parent is called, or something like that.
Python 2.6.6 (r266:84374, Aug 31 2010, 11:00:51) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import os.path >>> p = "/Users/ehsanakhgari/moz/mozgit/obj-ff-dbg/dist/NightlyDebug.app/Contents/MacOS/./application.ini" >>> os.path.dirname(p) '/Users/ehsanakhgari/moz/mozgit/obj-ff-dbg/dist/NightlyDebug.app/Contents/MacOS/.' normpath works: >>> os.path.normpath(p) '/Users/ehsanakhgari/moz/mozgit/obj-ff-dbg/dist/NightlyDebug.app/Contents/MacOS/application.ini'
Is there any reason why we should not adopt the normpath behavior?
See bug 744400, where this behavior breaks our updates in a weird way. Can somebody please respond to comment 3? If we don't fix this, basically any caller of nsIFile::GetParent() has a chance of getting the wrong directory out of it.
No longer blocks: bgupdates
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.