-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fmt: Fix relative paths with . and .. on Windows #4655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This is not correct: you need to actually process things with |
@daurnimator would that be a bug in the Windows Lines 3027 to 3032 in eaccfff
To be sure, you're thinking of a situation where the |
e.g. consider the path |
Forgive my naivete, but is there precedence for this? EDIT: Explorer brings me to |
Uh, I meant it'll take you to
It's a classic escape technique for attacking e.g. web servers (first example I found on google: https://www.inputzero.io/2019/05/webrick-path-traversal.html) How did you create the symlink? Also, try it on a linux machine :) |
(the openFileWindows line is from some debug printing I have locally, it shows the path used in I'm still confused about what you're describing. A concrete example would be really helpful (I'm not very knowledgeable about symlinks on any platform). |
As far as I can tell, |
c5b4e01
to
bbf7428
Compare
This is mergable in my opinion. Here's an attempt to make it easier to make a decision about: Pros
Cons
Notes on symlinks
Overall, I think the con is fairly minor and the current symlink-handling of |
This is a band-aid fix due to NtCreateFile failing on paths with . or .. in them.
bbf7428
to
99b140c
Compare
=> #5187 |
Added in ziglang#4655/ziglang#5187, obsoleted by ziglang#7664
This is one possible fix for #4605. It's sort-of a band-aid fix due to
NtCreateFile
failing on paths with.
or..
in them, so this resolves the paths viarealpath
before formatting them. The other possible fix would be to allow.
and..
to be passed toNtCreateFile
callers and deal with them appropriately within those functions (see #4659).Note: using
realpath
has a potential side-benefit of avoiding double-formatting paths that would resolve to the same path, since the real path is now used in theseen
map (sozig fmt ./test.zig test.zig
will now skip the second path since they both resolve to the same path).On Windows, here is before:
and after:
Closes #4605 if merged.
EDIT: See #4655 (comment) for "an attempt to make it easier to make a decision about [merging this]"